Quantcast

Author Topic: Super Basics of Lua (Work in Progress)  (Read 2689 times)

0 Members and 1 Guest are viewing this topic.

Offline LilDolla

  • IGC Founder
  • ******
  • In-Game Name: LilDolla
Super Basics of Lua (Work in Progress)
« on: March 02, 2018, 03:50:29 pm »
Common Types
  • Strings
  • Numbers
  • Tables

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.
--]]


maybe I should give you a name. but that's a slippery slope

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal