Lua Love

Some Great Lua Functions ❗

These are some functions I’ve used and thought were worth writing down.
I’m organizing them by category, for ease of navigation.

If you are using a language like PICO-8, and it has some slightly different names for its functions, use the language agnostic code snippet to make it work with your language of choice.


Language Agnostic 💬

-- pico-8 uses tostr instead of tostring, and this should fix it to work.
if type(tostring) ~= 'function' then
  tostring = tostr
else
  tostr = tostring
end

Table Functions 💽

-- Logs a table to the console in no fixed order
function pt(t)
  for k,v in pairs(t) do
    print(tostring(k)..": "..tostring(v))
  end
end