Tips for golfing in Lua What general tips do you have for golfing in Lua? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Lua (e.g. "remove comments" is not an answer). Please post one tip per answer.
In addition to the ones already posted, here are some tricks I've gathered over time, in no specific order...


For the function calls that only have one parameter delimited by a symbol (" for strings, { for tables), the parameter doesn't need to be wrapped around parentheses.
For example, instead of doing print("hello"), you can simply do : print"hello"
Remove as much whitespace as possible - this is especially easy to do after a symbol that closes strings (or before one opening), function calls, tables... Instead of print(42) a=1 you can do print(42)a=1. Other example: print(a and-1 or-2).
Use the ternary operator when you can! Instead of if a&gt;0 then print("hello") else print("goodbye") end, prefer print(a&gt;0 and "hello" or "goodbye"). More info here.
(This can actually get even better : print(a&gt;0 and"hello"or"goodbye"))
Use the colon-call syntactic sugar when you can : instead of string.rep(str,12), do str:rep(12). That also works on non-variables this way (and only this way) : ("a"):rep(5)
Instead of doing tonumber(str) just do str+0
For functions with no parameters, instead of defining them the usual way (function tick() blabla() end), you can do : ticks=loadstring"blabla()", which saves 1 or more bytes, depending on the content. Also, if you define multiple functions, localize loadstring to a 1-char variable before and you'll save a lot of bytes ;). Credits to Jim Bauwens for this trick.
Lua considers empty string (and 0 too unlike other languages) as true in conditional tests, so, for example, instead of doing while 1 do ... end, save 1 byte by writing while''do ... end