mirror of
https://github.com/celisej567/wiki.git
synced 2026-01-03 18:11:10 +03:00
199 lines
6.0 KiB
HTML
199 lines
6.0 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)
|
|
{
|
|
const nested = element.parentElement.querySelector(".nested");
|
|
if(nested.className.indexOf("active",0) != -1)
|
|
{
|
|
nested.className = "nested";
|
|
}
|
|
else
|
|
{
|
|
nested.className = "nested active";
|
|
}
|
|
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().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 {
|
|
list-style-type: none !important;
|
|
}
|
|
|
|
li b::before{
|
|
content:'+';
|
|
width:12px;
|
|
height:100%;
|
|
display: inline-block;
|
|
font-weight: 500;
|
|
}
|
|
|
|
|
|
li b.active::before
|
|
{
|
|
content: '-';
|
|
width:12px;
|
|
height:100%;
|
|
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;">
|
|
<p id="errorp"></p>
|
|
<h1>Lua Classes</h1>
|
|
|
|
<p>Let's start with an analogy. Imagine you want to make star-shaped cookies. You could of course, manually cut the baked cookie and then be left with a mess, or you could use a cookie cutter before baking it. In this analogy, the cookie is an object, the manual cutting method is using tables, and the cookie cutter is a class.</p>
|
|
|
|
<p>Before explaining what an object is, let's first take a look at how you even make a class.</p>
|
|
|
|
<p>To create a class, you first call the <code>class()</code> function like this:</p>
|
|
|
|
<pre><code>my_class = class() -- Creates a class creator
|
|
</code></pre>
|
|
|
|
<p><code>my_class</code> becomes a class creator. You can think of it like a bowl of ingredients which you can add to by simply setting the values of it.</p>
|
|
|
|
<pre><code>my_class = class() -- Creates a class creator
|
|
|
|
my_class.MyVar = 50.0 -- Creates a variable inside the class
|
|
function my_class.MyFunc(self,a) -- Creates a function inside the class
|
|
return self.MyVar+a
|
|
end
|
|
</code></pre>
|
|
|
|
<p>Once you are done with defining your class, you call the <code>finish()</code> function like this:</p>
|
|
|
|
<pre><code>finish(my_class) -- Finishes the class
|
|
</code></pre>
|
|
|
|
<p><code>my_class</code> will turn into a normal class where you cannot add any more variables or functions to it. In other words, <code>my_class</code> will get "baked" and you cannot add any more ingredients to it.</p>
|
|
|
|
<p>The <code>class()</code> function accepts another class as a parameter which will "inherit" the other class.</p>
|
|
|
|
<p>In simple terms, every function and variable from the other class, will be copied into yours, without having to specify them all over again.</p>
|
|
|
|
<pre><code>another_class = class(my_class) -- Inherits from my_class
|
|
|
|
another_class.MyVar = 20.0 -- Changes the existing variable
|
|
function another_class.NewFunc(self,b) -- Makes a new function
|
|
return self.MyVar-b
|
|
end
|
|
|
|
finish(another_class) -- Finishes it
|
|
</code></pre>
|
|
|
|
<p>We can now move on to objects.</p>
|
|
|
|
<hr />
|
|
|
|
<p><a href="/wiki/QScript/Lua/Objects.html">Next -></a></p>
|
|
|
|
</div> |