International Gaming Community

Outside IGC => Scripting => Topic started by: LilDolla on March 02, 2018, 03:50:29 pm

Title: Super Basics of Lua (Work in Progress)
Post by: LilDolla on March 02, 2018, 03:50:29 pm
Common Types

String
Code: (Lua) [Select]
local variable1 = "Hello World." -- This is a number
local variable2 = 21 -- This is a number
-- This is a table with 2 elements
local variable3 = {
    "Hello",
    221,
}



Lua can be considered a loosely typed language. For example a string variable can be easily converted into a number or a table.
Code: [Select]
local var1 = 2017

function changeVar1()
    var1 = "Two thousand and seventeen"
end
changeVar1()

This code snippet will convert var1 from a string type to a number type.



Lua, like most other languages, has the ability to provide comments in your code. You can provide single line and multiple line comments. Below are examples
Code: (Lua) [Select]
-- This is an example of a single line comment

--[[This is
an example
of a multi-line comment.
--]]

SimplePortal 2.3.7 © 2008-2024, SimplePortal