Difference between revisions of "Lua to Luau conversion guide"

From GiderosMobile
(fixed Pages with syntax highlighting errors)
m
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Gideros 2022.1 changed the interpreter from the Gideros flavour of Lua to the Gideros flavour of Luau:'''
+
The Ultimate Guide to Gideros Studio
  
Luau (lowercase u, /ˈlu.aʊ/) is a fast, small, safe, gradually typed embeddable scripting language derived from Lua.  See: https://luau-lang.org/
+
__TOC__
  
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:
+
'''Gideros 2022.1 changed the interpreter from the Gideros flavour of Lua to the Gideros flavour of Luau:'''
  
== Macros are no longer present, you will need to change macro constants to variables: ==
+
'''Luau''' (lowercase u, /ˈlu.aʊ/) is a fast, small, safe, gradually typed embeddable scripting language derived from Lua. See: '''https://luau-lang.org/'''
e.g.
 
  
 +
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.
 +
 +
However there are some slight differences between new Gideros Luau and old Gideros Lua.
 +
 +
== Macros are no longer present, you will need to change macro constants to variables ==
 +
'''e.g.'''
 +
<syntaxhighlight lang="lua">
 
maxLives@5
 
maxLives@5
 +
</syntaxhighlight>
  
change to:
+
'''change to:'''
 
+
<syntaxhighlight lang="lua">
 
maxLives=5
 
maxLives=5
 +
</syntaxhighlight>
  
 
== Automatic 'arg' variable in variadic argument functions is no longer available ==
 
== Automatic 'arg' variable in variadic argument functions is no longer available ==
 
Preferred and lua compatible way is to declare it yourself:
 
Preferred and lua compatible way is to declare it yourself:
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
function foo(...)
 
function foo(...)
 
local arg = {...}
 
local arg = {...}
 
end
 
end
</source>
+
</syntaxhighlight>
  
== string.gsub patterns act slightly different when replacing a character that is special, you need to remove the second %: ==
+
== string.gfind was removed, use string.gmatch instead ==
e.g.
+
'''e.g.'''
 +
<syntaxhighlight lang="lua">
 +
for char in string.gfind("ABC", "([%z\1-\127\194-\244][\128-\191]*)") do
 +
</syntaxhighlight>
  
 +
'''change to:'''
 +
<syntaxhighlight lang="lua">
 +
for char in string.gmatch("ABC", "([%z\1-\127\194-\244][\128-\191]*)") do print(char) end
 +
</syntaxhighlight>
 +
 +
== string.gsub patterns act slightly different when replacing a character that is special, you need to remove the second % ==
 +
'''e.g.'''
 +
<syntaxhighlight lang="lua">
 
string.gsub(myString,"%+","%-")
 
string.gsub(myString,"%+","%-")
 +
</syntaxhighlight>
  
change to:
+
'''change to:'''
 +
<syntaxhighlight lang="lua">
 +
string.gsub(myString,"%+","-")
 +
</syntaxhighlight>
  
string.gsub(myString,"%+","-")
+
== Lua shaders need to have a slight change to the way they are defined ==
 +
'''e.g.'''
 +
<syntaxhighlight lang="lua">
 +
function vertex(vVertex,vColor,vTexCoord)
 +
</syntaxhighlight>
  
== Lua shaders need to have a slight change to the way they are defined: ==
+
'''change to:'''
e.g.
+
<syntaxhighlight lang="lua">
 +
function vertex(vVertex,vColor,vTexCoord):Shader
 +
</syntaxhighlight>
  
function vertex(vVertex,vColor,vTexCoord)
 
  
change to:
+
'''PREV.''': [[Introduction]]<br/>
 +
'''NEXT''': [[Gideros Studio]]
  
function vertex(vVertex,vColor,vTexCoord):Shader
 
  
 
{{GIDEROS IMPORTANT LINKS}}
 
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 06:15, 19 January 2025

The Ultimate Guide to Gideros Studio

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.

However there are some slight differences between new Gideros Luau and old Gideros Lua.

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.gfind was removed, use string.gmatch instead

e.g.

for char in string.gfind("ABC", "([%z\1-\127\194-\244][\128-\191]*)") do

change to:

for char in string.gmatch("ABC", "([%z\1-\127\194-\244][\128-\191]*)") do print(char) 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


PREV.: Introduction
NEXT: Gideros Studio