mirror of
https://github.com/celisej567/wiki.git
synced 2026-09-21 20:08:53 +03:00
More elaboration
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<!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']
|
||||
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 updateSearch() {
|
||||
searchtext = document.getElementById("searchbox").value.toLowerCase();
|
||||
@@ -44,7 +44,11 @@ pre {
|
||||
<div style="margin-left:200px;">
|
||||
<h1>Lua Classes</h1>
|
||||
|
||||
<p>If you want to create a class, you first call the <code>class()</code> function like this:</p>
|
||||
<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>
|
||||
@@ -72,17 +76,16 @@ end
|
||||
|
||||
<pre><code>another_class = class(my_class) -- Inherits from my_class
|
||||
|
||||
another_class.MyVar = 20.0 -- Overrides the built-in variable
|
||||
function another_class.NewFunc(self,b)
|
||||
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
|
||||
|
||||
another_class.MyFunc(5) -- Will return 25
|
||||
another_class.NewFunc(5) -- Will return 15
|
||||
</code></pre>
|
||||
|
||||
<p>We can now move on to objects.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<p><a href="/wiki/QScript/Lua/Objects.html">Next -></a></p>
|
||||
|
||||
Reference in New Issue
Block a user