Files
wiki/dst/QScript/Lua/Exports.html
relt-1 0437a3ea35 Maybe fix PS3 compatibility
You cannot get a more based commit name than that
2023-09-24 09:06:54 +02:00

165 lines
4.6 KiB
HTML

<!DOCTYPE html>
<title>SourceBox Wiki</title>
<script>
const documentlist = ['/wiki/index.html', '/wiki/QScript/Introduction.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/Tutorial/Chapter1.html']
const namelist = ['Wiki Intro', 'QScript Intro', 'Lua Classes', 'Lua Exports', 'Lua Imports', 'Lua Intro', 'Lua Objects', 'QScript Tutorial Chapter 1']
function toggleTree(element)
{
element.parentElement.querySelector(".nested").classList.toggle("active");
element.classList.toggle("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().includes(searchtext)) 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;
}
.active {
display: block !important;
}
ul {
padding-left: 8px;
}
li ::marker {
color:#00000000;
display:none;
}
li b::before{
content:'+';
width:12px;
height:8px;
display: inline-block;
font-weight: 500;
}
li b.active::before
{
content: '-';
width:12px;
height:8px;
display: inline-block;
font-weight: 500;
}
li b {
cursor: pointer;
display: block;
}
</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><b onclick="toggleTree(this);">QScript</b>
<ul class="nested">
<li><a href="/wiki/QScript/Introduction.html">QScript Intro</a></li>
<li><b onclick="toggleTree(this);">Lua</b>
<ul class="nested">
<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><b onclick="toggleTree(this);">Python</b>
<ul class="nested">
</ul>
</li>
<li><b onclick="toggleTree(this);">Squirrel</b>
<ul class="nested">
</ul>
</li>
<li><b onclick="toggleTree(this);">Tutorial</b>
<ul class="nested">
<li><a href="/wiki/QScript/Tutorial/Chapter1.html">QScript Tutorial Chapter 1</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</div>
<div style="margin-left:200px;">
<h1>Lua Exports</h1>
<p>Here is the real meat and potatoes of QScript. The import/export system allows you to share objects, functions and classes between scripts and other languages! The system is stupidly simple to understand.</p>
<p>Here is a simple code example:</p>
<pre><code>function Add(a,b)
return a + b
end
export(Add)
</code></pre>
<p>That is it! Just put the global variable you want to export in the global scope (not inside another function) and the thing you want to export will get added to a special list which will contain all the exported elements from your file.</p>
<p>Exporting classes and objects works the same way.</p>
<pre><code>my_class = class()
finish(my_class)
my_object = object(my_class)
export(my_class)
export(my_object)
</code></pre>
<p>That's great but now what can you do with the exported variables? That's the thing. You don't! Other scripts use the exported variables. See how and why in the next page.</p>
<hr />
<p><a href="/wiki/QScript/Lua/Objects.html">&lt;- Prev</a> |
<a href="/wiki/QScript/Lua/Imports.html">Next -></a></p>
</div>