I am not too experienced with Lua at the moment. This document will go over my knowledge of the Lua language so far.
This document used version 5.4 of the Lua programming language.
Comments in Lua are the same as comments in languages like Ada, SQL, Haskell, VHDL, Elm, etc.
-- This is a single line comment
-- Lua does not support multi-line comments (as far as I know)
break
To this day, I am still not entirely sure what the break
keyword does, but most languages support it.
/!\ This example has not been tested yet, and may not work
A hello world program in Lua is pretty simple. It is similar to Python, Perl, etc..
print ("Hello World")
It can also be written without parentheses
print "Hello World"
And doesn't require double quotation marks (singluar quotes work as well)
print 'Just another Lua hacker'
The process of making functions in Lua is pretty simple:
-- An empty function
local function1
function1 = function() end
function1()
-- A hello world function
local function2
function2 = function()
print("Hello World function has functionally functioned")
end
function2()
/!\ This example has not been tested yet, and may not work
Calling a function in Lua is very easy, and similar to many languages, such as Python, MoonScript, Rust, C, etc.
function1()
Classes are supported in Lua. They can be defined like so:
local myLuaClass
do
print("Welcome to my Lua class")
end
/!\ This example has not been tested yet, and may not work
The majority of my Lua knowledge comes from the official MoonScript developer reference it has proven extremely helpful for both MoonScript and Lua, although some of my knowledge comes from self-experimentation with Lua and Wikipedia.
-
Lua is a curly bracket language, but does not use semicolons at the end of each line
-
MoonScript and Amulet are languages that compile to Lua
-
Lua uses the
.lua
file extension -
Lua was created in 1993
-
Lua is an open source programming language
-
No other knowledge of Lua at the moment.
File version: 1 (2022, Wednesday, April 13th at 8:11 pm PST)