Difference between revisions of "Lua to Luau conversion guide"

From GiderosMobile
(fixed Pages with syntax highlighting errors)
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''Macros are no longer present, you will need to change macro constants to variables:'''
+
'''Gideros 2022.1 changed the interpreter from the Gideros flavour of Lua to the Gideros flavour of Luau:'''
  
 +
Luau (lowercase u, /ˈlu.aʊ/) is a fast, small, safe, gradually typed embeddable scripting language derived from Lua.  See: https://luau-lang.org/
 +
 +
Unlike regular Luau, Gideros Luau has the custom operators (bitwise, larger, smaller, trigonometry and integer divide) and easier syntax for arrays that you are used to with Gideros Lua.  There are some slight differences however:
 +
 +
== Macros are no longer present, you will need to change macro constants to variables: ==
 
e.g.
 
e.g.
  
Line 9: Line 14:
 
maxLives=5
 
maxLives=5
  
 +
== Automatic 'arg' variable in variadic argument functions is no longer available ==
 +
Preferred and lua compatible way is to declare it yourself:
 +
<source lang="lua">
 +
function foo(...)
 +
local arg = {...}
 +
end
 +
</source>
  
'''string.gsub patterns act slightly different when replacing a character that is special, you need to remove the second %:'''
+
== string.gsub patterns act slightly different when replacing a character that is special, you need to remove the second %: ==
 
 
 
e.g.
 
e.g.
  
Line 20: Line 31:
 
string.gsub(myString,"%+","-")
 
string.gsub(myString,"%+","-")
  
 
+
== Lua shaders need to have a slight change to the way they are defined: ==
'''Lua shaders need to have a slight change to the way they are defined:'''
 
 
 
 
e.g.
 
e.g.
  
Line 30: Line 39:
  
 
function vertex(vVertex,vColor,vTexCoord):Shader
 
function vertex(vVertex,vColor,vTexCoord):Shader
 +
 +
{{GIDEROS IMPORTANT LINKS}}

Revision as of 21:43, 22 January 2023

Gideros 2022.1 changed the interpreter from the Gideros flavour of Lua to the Gideros flavour of Luau:

Luau (lowercase u, /ˈlu.aʊ/) is a fast, small, safe, gradually typed embeddable scripting language derived from Lua. See: https://luau-lang.org/

Unlike regular Luau, Gideros Luau has the custom operators (bitwise, larger, smaller, trigonometry and integer divide) and easier syntax for arrays that you are used to with Gideros Lua. There are some slight differences however:

Macros are no longer present, you will need to change macro constants to variables:

e.g.

maxLives@5

change to:

maxLives=5

Automatic 'arg' variable in variadic argument functions is no longer available

Preferred and lua compatible way is to declare it yourself:

function foo(...)
	local arg = {...}
end

string.gsub patterns act slightly different when replacing a character that is special, you need to remove the second %:

e.g.

string.gsub(myString,"%+","%-")

change to:

string.gsub(myString,"%+","-")

Lua shaders need to have a slight change to the way they are defined:

e.g.

function vertex(vVertex,vColor,vTexCoord)

change to:

function vertex(vVertex,vColor,vTexCoord):Shader