Community
RESOURCES
8
Movable Character on a MapFeel free to use this however you want!
Easy Working Movable Character On Map Template!
An easy "copy & paste" map! Feel free to use it however you want, Instructions for use provided.463
7
8
3
Python Movement SystemAn elegant movement system written in Python. Feel free to fork this for use in your own game.
1
Beginner Lua Tutorial!
Hello! Today I'll be explaining the basics of Lua.
Strings
Let's start by something easy, the strings. There are 3 types of strings. We'll only be interested in 2 of those types of strings.
"This is the most common string"
'This is used often too'
[["Used way less, but really useful for advanced programming."]]
You'll need strings everywhere with Lua.
Hello World!
Let's learn the famous Hello World Program in Lua. You need to use print . When printing, make sure you put strings in between the text to print, or otherwise it'll print nil.
print("Hello World!")
Pretty easy, right?
Comment
I don't really know the actual name, but it allows you to write information while it doesn't count as code.
-- this is a comment
Boolean
A boolean value is simple:
true
false
false
those 3 are boolean values. It's pretty self explanatory.
You can print booleans without using strings, same for printing numbers.
Variables
You can set variables pretty easily.
Variable = 0
If you need to use the Variable only once in the same code block or so, you can set a local variabe.
local Variable = 0
Those variables can hold strings, booleans,numbers and others.
Function
Set a function or (if you're doing a simple/beginner program) local function.
functions can execute multiple lines of code if an event happens or if you call that certain function. You end the code block in a function with the keyword end.
local function Func()
print("Hi!")
print("Hi V2")
end
Func() -- function called
Just like that, you learned 3 of the 21 keywords in Lua.
local, function and end.
You can make the function return a certain value after being called. You can also set a variable that the function will be using.
local function Hello(a) -- a is now a local
return a -- the only thing this function does is returning the value of a.
end
local function Hello2(a) -- a must be a number for this function.
print(a)
a = a + 1
return a
end
Array
There is only 1 type of array in Lua. It is named a "Table". It can hold any value(including booleans) except nil.
local myTable = {"Hi","How are you?",3,true,"Helloooo"}
Loops
there are 3 keywords to make loops in lua. for,while,repeat.
while
while is an infinite loop that never ends no matter what.
if you want the while loop to be executed, you only need to do this:
while true do -- the value must be true to be executed. if it's false, nothing will happen.
print("ahah")
end
-- this will print ahah forever.for
for loops are really useful.
you set variable to an init and it'll loop for an amount of time chosen.
for i = 1,10 do
print(i)
end
this'll print in different lines, 1 to 10.
you can make it more custom with this however:
for i = 10,1,-1 do -- 10 is the limit, 1 is where the loop ends, -1 is the degree of how much it jumps down.
print(i)
end
-- now this will print 10 to 1 in different lines.Repeat
Repeat will repeat a code block until the chosen value becomes true.
repeat
print("ahah")
until 2+2==5 -- must be 2 ='s because one equal symbol means you're changing something.
This will print ahah forever, since 2+2 will never equal 5.
if
if works pretty easily. It is a condition; You need a true value, and it'll execute.
if true then
-- code block
end
else, elseif
Let's say you want it to be more customized. You would use else and elseif. else is simple: if the if is false, the code block in else will be executed. For example:
local Num1 = 1
if Num1 == 0 then
print("lol")
else
print("bruh")
end
-- the output would be bruh since Num1 is not equal to 0.
elseif is the same as else, but instead, it allows you to re-use if. To prevent the codeblock in else to be implicitely returned, use elseif to use if in else.
local Num1 = 1
if Num1 == 0 then
print("hi")
elseif Num1 == 2 then
print("cool") -- both of these are false.
else -- add an else in case all the above are false.
print("This should be the output!")
end
and,or
and & or are literally what they mean. use them in if or elseif.
If you use an and, both (or the amount of times you put an and) of the conditions must be true. otherwise, if just one of them are false, the whole condition becomes false.
local Num1 = 10
local Num2 = 3
if Num1 == 10 and Num2 == 2 then
print("Success")
elseif Num1 == 10 and Num2 == 4 then
print("Hello there")
elseif Num1 == 10 and Num2 == 3 then
print("This should be the output!")
end
or is the same thing. If only a single condition is true, the condition gets executed.
local Num1 = 10
if Num1 == 9 or Num1 == 10 then
print("This should be the output")
end