Files
wiki/dst/QScript/Lua/Objects.html
2023-09-23 15:37:48 +02:00

67 lines
2.7 KiB
HTML

<!DOCTYPE html>
<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/Objects.html', '/wiki/QScript/Tutorial/Chapter1.html']
const namelist = ['Wiki Intro', 'QScript Intro', 'Lua Classes', 'Lua Exports', 'Lua Imports', 'Lua Objects', 'QScript Tutorial Chapter 1']
function updateSearch() {
searchtext = document.getElementById("searchbox").value.toLowerCase();
var res = [];
var searchresults = document.getElementById("searchresults")
searchresults.innerHTML = ""
if(searchtext === "")
return;
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;
}
</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>
</nav>
</div>
<div style="margin-left:200px;">
<h1>Lua Objects</h1>
<p>Objects store a number of variables and functions which are defined in the class the object comes from. They kind of act like tables but are not modifiable. Meaning, if you wanted to make a new variable or function inside an object, you would get an error.</p>
<p>Another thing that is different from tables is that you cannot change the type of the variables. Once they have been defined, that's it. You cannot change that variable to any other type which it originally was defined with.</p>
<p>To create a new object, simply call the <code>object()</code> function with a class, and it will return a new object based on the class you gave it.</p>
<pre><code>my_class = class() -- Start creating the class
my_class.var = 10.0 -- Make a variable
finish(my_class) -- Finish the class
my_object = object(my_class) -- Make the object
</code></pre>
<hr />
<p><a href="/wiki/QScript/Lua/Classes.html">&lt;- Prev</a> |
<a href="/wiki/QScript/Lua/Exports_Imports.html">Next -></a></p>
</div>