More elaboration

This commit is contained in:
relt-1
2023-09-23 17:00:30 +02:00
parent b43b843f03
commit b7c22b3c7d
15 changed files with 130 additions and 29 deletions

View File

@@ -33,7 +33,13 @@ for root, subdirs, files in os.walk(src):
fpath = os.path.join(root, file)
with open(fpath,"r") as f:
with open(dst+fpath[len(src):].replace(".md",".html"), "w") as r:
converted = mark.convert(f.read())
rawmarkdown = f.read().replace("\r\n","\n")
smalls = re.findall(r"^\S+\n[( )\t]",rawmarkdown,re.MULTILINE)
for small in smalls:
smallstring = small.strip()
whitespace = small[len(smallstring):]
rawmarkdown = rawmarkdown.replace(small, "<small style=\"position:relative; top:16px;\">"+smallstring+"</small>\n"+whitespace)
converted = mark.convert(rawmarkdown)
links = re.findall(r'\[\[.+\]\]', converted)
for link in links:
converted = converted.replace(link, "<a href=\"/wiki/"+link[2:-2]+".html\">"+link[2:-2].split("/")[-1]+"</a>")

View File

@@ -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();

View File

@@ -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>

View File

@@ -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();
@@ -69,6 +69,8 @@ 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> |

View File

@@ -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();
@@ -48,8 +48,9 @@ pre {
<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>
<pre><code>-- MyMod/MyLib.lua
function add(a,b)
<p><small style="position:relative; top:16px;">MyMod/MyLib.lua</small></p>
<pre><code>function add(a,b)
return a + b
end
@@ -65,6 +66,8 @@ MyLib.add(5,7) -- Will return 12
<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">&lt;- Prev</a></p>

View File

@@ -0,0 +1,51 @@
<!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/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();
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 Intro</h1>
<p>The tutorial will assume that you already know the basics of Lua. If you do not know anything about it, then you can go to <a href="https://www.lua.org/pil/contents.html">the official PIL</a></p>
<p>First, let's learn about <a href="/wiki/QScript/Lua/Classes.html">Lua Classes</a></p>
</div>

View File

@@ -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();
@@ -59,6 +59,8 @@ finish(my_class) -- Finish the class
my_object = object(my_class) -- Make the object
</code></pre>
<p>Why would you use an object instead of a table? Well, you'll soon see why.</p>
<hr />
<p><a href="/wiki/QScript/Lua/Classes.html">&lt;- Prev</a> |

View File

@@ -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,4 +44,14 @@ pre {
<div style="margin-left:200px;">
<h1>QScript Tutorial Chapter 1</h1>
<p>Currently, only a short documentation of Lua is available. </p>
<p>Languages:</p>
<ul>
<li><p><a href="/wiki/QScript/Lua/Intro.html">Lua</a></p></li>
<li><p>Squirrel</p></li>
<li><p>Python</p></li>
</ul>
</div>

View File

@@ -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();

View File

@@ -1,6 +1,10 @@
# Lua Classes
If you want to create a class, you first call the `class()` function like this:
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.
Before explaining what an object is, let's first take a look at how you even make a class.
To create a class, you first call the `class()` function like this:
my_class = class() -- Creates a class creator
@@ -31,15 +35,14 @@ In simple terms, every function and variable from the other class, will be copie
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
We can now move on to objects.
---

View File

@@ -23,6 +23,8 @@ Exporting classes and objects works the same way.
export(my_class)
export(my_object)
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.
---
[<- Prev][QScript/Lua/Objects] |

View File

@@ -4,7 +4,8 @@ Now that you have exported some variables, something's gotta import them! As alw
Let's say that you have made a file called "MyLib.lua" inside a mod called "MyMod". These are the contents of it:
-- MyMod/MyLib.lua
MyMod/MyLib.lua
function add(a,b)
return a + b
end
@@ -19,6 +20,8 @@ Now you want to import it inside another file. You call the `import()` function
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!)
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 *same* object, not copies of it.
---
[<- Prev][QScript/Lua/Exports]

5
src/QScript/Lua/Intro.md Normal file
View File

@@ -0,0 +1,5 @@
# Lua Intro
The tutorial will assume that you already know the basics of Lua. If you do not know anything about it, then you can go to [the official PIL](https://www.lua.org/pil/contents.html)
First, let's learn about [Lua Classes][QScript/Lua/Classes]

View File

@@ -14,6 +14,8 @@ To create a new object, simply call the `object()` function with a class, and it
my_object = object(my_class) -- Make the object
Why would you use an object instead of a table? Well, you'll soon see why.
---
[<- Prev][QScript/Lua/Classes] |

View File

@@ -1,2 +1,11 @@
# QScript Tutorial Chapter 1
Currently, only a short documentation of Lua is available.
Languages:
* [Lua][QScript/Lua/Intro]
* Squirrel
* Python