Skip to content

Available Lua functions

Alex May edited this page Mar 25, 2020 · 1 revision

For security, the MOO supports a subsection of the default Lua libraries using a technique called Sandboxing.

This is designed to restrict users in two ways:

  1. being able to manipulate the Lua environment to escape the sandbox
  2. to execute arbitrary code or processes outside of the sandbox that would affect the wider system

The following functions are available inside the MOO sandbox. Details of each are in the Lua 5.1 manual):

Base Library

  • assert (v [, message])
  • error (message [, level])
  • ipairs (t)
  • next (table [, index])
  • pairs (t)
  • pcall (f, arg1, ···)
  • select (index, ···)
  • tonumber (e [, base])
  • tostring (e)
  • type (v)
  • unpack (list [, i [, j]])

String Library

  • string.byte (s [, i [, j]])
  • string.char (···)
  • string.dump (function)
  • string.find (s, pattern [, init [, plain]])
  • string.format (formatstring, ···)
  • string.gmatch (s, pattern)
  • string.gsub (s, pattern, repl [, n])
  • string.len (s)
  • string.lower (s)
  • string.match (s, pattern [, init])
  • string.rep (s, n)
  • string.reverse (s)
  • string.sub (s, i [, j])
  • string.upper (s)

Table Library

  • table.concat (table [, sep [, i [, j]]])
  • table.insert (table, [pos,] value)
  • table.maxn (table)
  • table.remove (table [, pos])
  • table.sort (table [, comp])

Math Library

  • math.abs (x)
  • math.acos (x)
  • math.asin (x)
  • math.atan (x)
  • math.atan2 (y, x)
  • math.ceil (x)
  • math.cos (x)
  • math.cosh (x)
  • math.deg (x)
  • math.exp (x)
  • math.floor (x)
  • math.fmod (x, y)
  • math.frexp (x)
  • math.huge
  • math.ldexp (m, e)
  • math.log (x)
  • math.log10 (x)
  • math.max (x, ···)
  • math.min (x, ···)
  • math.modf (x)
  • math.pi
  • math.pow (x, y)
  • math.rad (x)
  • math.random ([m [, n]])
  • math.randomseed (x)
  • math.sin (x)
  • math.sinh (x)
  • math.sqrt (x)
  • math.tan (x)
  • math.tanh (x)

Operating System Library

  • os.clock ()
  • os.date ([format [, time]])
  • os.difftime (t2, t1)
  • os.time ([table])
Clone this wiki locally