mirror of
https://github.com/celisej567/wiki.git
synced 2026-09-09 20:10:37 +03:00
199 lines
8.0 KiB
HTML
199 lines
8.0 KiB
HTML
<!DOCTYPE html>
|
|
<title>SourceBox Wiki</title>
|
|
<script>
|
|
documentlist = ['/wiki/index.html', '/wiki/QScript/Introduction.html', '/wiki/QScript/Private_Members.html', '/wiki/QScript/Contributing/Contributing.html', '/wiki/QScript/Contributing/API/qscript.html', '/wiki/QScript/Contributing/API/Structs/QCFunc.html', '/wiki/QScript/Contributing/API/Structs/QModuleDefFunc.html', '/wiki/QScript/Contributing/API/Structs/QScriptCallback.html', '/wiki/QScript/Contributing/API/Structs/QScriptClass.html', '/wiki/QScript/Contributing/API/Structs/QScriptClassCreator.html', '/wiki/QScript/Contributing/API/Structs/QType.html', '/wiki/QScript/Contributing/API/Structs/QValue.html', '/wiki/QScript/Lua/Classes.html', '/wiki/QScript/Lua/Exports.html', '/wiki/QScript/Lua/Imports.html', '/wiki/QScript/Lua/Intro.html', '/wiki/QScript/Lua/Objects.html', '/wiki/QScript/Squirrel/Exports_And_Imports.html', '/wiki/QScript/Squirrel/Intro.html', '/wiki/QScript/Tutorial/Chapter1.html', '/wiki/QScript/Tutorial/Chapter2.html'];
|
|
namelist = ['Wiki Intro', 'QScript Intro', 'Private Members', 'Contributing', 'QScript API', 'QCFunc', 'QModuleDefFunc', 'QScriptCallback', 'QScriptClass', 'QScriptClassCreator', 'QType', 'QValue', 'Lua Classes', 'Lua Exports', 'Lua Imports', 'Lua Intro', 'Lua Objects', 'Squirrel Exports and Imports', 'Squirrel Intro', 'QScript Tutorial Page 1: Mods', 'QScript Tutorial Page 2: Getting to work'];
|
|
|
|
function toggleTree(element)
|
|
{
|
|
nested = element.parentNode.childNodes[3];
|
|
if(nested.className.indexOf("active",0) != -1)
|
|
{
|
|
nested.className = "nested";
|
|
element.parentNode.childNodes[0].innerHTML = "+";
|
|
}
|
|
else
|
|
{
|
|
nested.className = "nested active";
|
|
element.parentNode.childNodes[0].innerHTML = "-";
|
|
}
|
|
if(element.className.indexOf("active",0) != -1)
|
|
{
|
|
element.className = ""
|
|
}
|
|
else
|
|
{
|
|
element.className = "active"
|
|
}
|
|
}
|
|
|
|
function updateSearch() {
|
|
searchtext = document.getElementById("searchbox").value.toLowerCase();
|
|
var res = [];
|
|
var searchresults = document.getElementById("searchresults")
|
|
searchresults.innerHTML = ""
|
|
if(searchtext === "")
|
|
{
|
|
document.getElementById("filetree").style.display = "block"
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
document.getElementById("filetree").style.display = "none"
|
|
}
|
|
for (var i = 0; i < namelist.length; i++)
|
|
{
|
|
if(namelist[i].toLowerCase().indexOf(searchtext) == -1) continue;
|
|
var searchelement = document.createElement("li");
|
|
var link = document.createElement("a");
|
|
searchelement.appendChild(link);
|
|
link.setAttribute("href", documentlist[i]);
|
|
link.innerHTML = namelist[i];
|
|
searchresults.appendChild(searchelement);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
</script>
|
|
<style>
|
|
pre {
|
|
margin-left:16px;
|
|
background-color: #EEE;
|
|
border-color: #CCC;
|
|
border-style:solid;
|
|
border-width:1px;
|
|
}
|
|
.nested {
|
|
display: none;
|
|
border-left: 1px solid #000;
|
|
}
|
|
|
|
ul.active {
|
|
display: block !important;
|
|
}
|
|
|
|
ul {
|
|
padding-left: 8px;
|
|
}
|
|
|
|
li ::marker {
|
|
color:#00000000;
|
|
display:none;
|
|
}
|
|
|
|
li {
|
|
list-style-type: none !important;
|
|
}
|
|
|
|
li b {
|
|
cursor: pointer;
|
|
display: inline-block;
|
|
}
|
|
|
|
.liicon {
|
|
display:inline-block;
|
|
width:12px;
|
|
height:100%;
|
|
font-family: monospace;
|
|
font-size: 16px;
|
|
}
|
|
|
|
</style>
|
|
<div style="position:fixed; display:block; top: 0px; left: 0px; height:100%; width:200px;border-color: black; border-width: 1px; border-style:solid;">
|
|
<input type="text" placeholder="search..." autocomplete="off" id="searchbox" oninput="updateSearch();" style="width:192px;">
|
|
<nav>
|
|
<ul id="searchresults">
|
|
</ul>
|
|
<ul id="filetree">
|
|
<li><a href="/wiki/index.html">Wiki Intro</a></li>
|
|
<li><small class="liicon">-</small><b onclick="toggleTree(this);">QScript</b>
|
|
<ul class="nested active">
|
|
<li><a href="/wiki/QScript/Introduction.html">QScript Intro</a></li>
|
|
<li><a href="/wiki/QScript/Private_Members.html">Private Members</a></li>
|
|
<li><small class="liicon">+</small><b onclick="toggleTree(this);">Contributing</b>
|
|
<ul class="nested">
|
|
<li><a href="/wiki/QScript/Contributing/Contributing.html">Contributing</a></li>
|
|
<li><small class="liicon">+</small><b onclick="toggleTree(this);">API</b>
|
|
<ul class="nested">
|
|
<li><a href="/wiki/QScript/Contributing/API/qscript.html">QScript API</a></li>
|
|
<li><small class="liicon">+</small><b onclick="toggleTree(this);">Structs</b>
|
|
<ul class="nested">
|
|
<li><a href="/wiki/QScript/Contributing/API/Structs/QCFunc.html">QCFunc</a></li>
|
|
<li><a href="/wiki/QScript/Contributing/API/Structs/QModuleDefFunc.html">QModuleDefFunc</a></li>
|
|
<li><a href="/wiki/QScript/Contributing/API/Structs/QScriptCallback.html">QScriptCallback</a></li>
|
|
<li><a href="/wiki/QScript/Contributing/API/Structs/QScriptClass.html">QScriptClass</a></li>
|
|
<li><a href="/wiki/QScript/Contributing/API/Structs/QScriptClassCreator.html">QScriptClassCreator</a></li>
|
|
<li><a href="/wiki/QScript/Contributing/API/Structs/QType.html">QType</a></li>
|
|
<li><a href="/wiki/QScript/Contributing/API/Structs/QValue.html">QValue</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li><small class="liicon">-</small><b onclick="toggleTree(this);">Lua</b>
|
|
<ul class="nested active">
|
|
<li><a href="/wiki/QScript/Lua/Classes.html">Lua Classes</a></li>
|
|
<li><a href="/wiki/QScript/Lua/Exports.html">Lua Exports</a></li>
|
|
<li><a href="/wiki/QScript/Lua/Imports.html">Lua Imports</a></li>
|
|
<li><a href="/wiki/QScript/Lua/Intro.html">Lua Intro</a></li>
|
|
<li><a href="/wiki/QScript/Lua/Objects.html">Lua Objects</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><small class="liicon">+</small><b onclick="toggleTree(this);">Python</b>
|
|
<ul class="nested">
|
|
</ul>
|
|
</li>
|
|
<li><small class="liicon">+</small><b onclick="toggleTree(this);">Squirrel</b>
|
|
<ul class="nested">
|
|
<li><a href="/wiki/QScript/Squirrel/Exports_And_Imports.html">Squirrel Exports and Imports</a></li>
|
|
<li><a href="/wiki/QScript/Squirrel/Intro.html">Squirrel Intro</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><small class="liicon">+</small><b onclick="toggleTree(this);">Tutorial</b>
|
|
<ul class="nested">
|
|
<li><a href="/wiki/QScript/Tutorial/Chapter1.html">QScript Tutorial Page 1: Mods</a></li>
|
|
<li><a href="/wiki/QScript/Tutorial/Chapter2.html">QScript Tutorial Page 2: Getting to work</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
<div style="margin-left:200px;">
|
|
<p id="errorp"></p>
|
|
<h1>Lua Imports</h1>
|
|
|
|
<p>Now that you have exported some variables, something's gotta import them! As always, it is very simple to do.</p>
|
|
|
|
<p>Let's say that you have made a file called "MyLib.lua" inside a mod called "MyMod". These are the contents of it:</p>
|
|
|
|
<p><small style="position:relative; top:16px;">MyMod/MyLib.lua</small></p>
|
|
|
|
<pre><code>function add(a,b)
|
|
return a + b
|
|
end
|
|
|
|
export(add)
|
|
</code></pre>
|
|
|
|
<p>Now you want to import it inside another file. You call the <code>import()</code> function with the file name of the thing you want to import. It will return a table containing all the exported variables.</p>
|
|
|
|
<pre><code>MyLib = import("MyMod/MyLib.lua") -- Import the library
|
|
|
|
MyLib.add(5,7) -- Will return 12
|
|
</code></pre>
|
|
|
|
<p>Importing works between other languages. So you don't need to worry about a library being written in a different language than you would like. (You could even use multiple languages in one project! Think about that!)</p>
|
|
|
|
<p>The reason why you can't use tables, is because objects, are actually shared! One script can modify it (like set a variable), and every other script will also see the change. Tables differ between languages, meaning that having to manually sync them between eachother would be a bad idea. Here, you only get a "reference" to the object. Meaning that every script sees the <em>same</em> object, not copies of it.</p>
|
|
|
|
<hr />
|
|
|
|
<p><a href="/wiki/QScript/Lua/Exports.html"><- Prev</a> |
|
|
<a href="/wiki/QScript/Tutorial/Chapter1.html">Go back to the QScript Tutorial</a></p>
|
|
|
|
</div> |