Skip to content

Lua MOO reference

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

This page lists all the objects, functions, and properties that are available in the MOO programming environment that are not part of the standard Lua libraries.

  • nil means the method/functions doesn't return anything
  • {type} means the method/function/argument is a table (Lua's name for its list/map/vector) of type
  • variant means the a value that might be of several different types
  • ... means a variable number of inputs or outputs

Object access

Always available

  • object moo.root() - the root object
  • object moo.last() - the last object created
  • object moo.system() - the system object

Available during verb/task

  • object moo.object()
  • string moo.verb()
  • {string} moo.args()
  • string moo.argstr()
  • object moo.caller()
  • object moo.here()
  • object moo.me()
  • object moo.player()
  • object moo.dobj()
  • string moo.dobjstr()
  • object moo.iobj()
  • string moo.iobjstr()
  • string moo.prepstr()
  • object moo.programmer()

Global functions

  • int moo.timestamp()
  • nil moo.notify( string )
  • ... moo.pass( ... )
  • ... moo.eval( ... )
  • nil moo.debug( string message )
  • string moo.hash( string v ) - returns the SHA256 hash of v
  • object moo.find_player( string name ) - finds a player object
  • object moo.find_by_prop( string propname, variant propvalue )
  • nil moo.get( string url, object o, string verbname ) - read data from a URL
  • nil moo.read()
  • nil moo.read( table args )
  • nil moo.read( object o, string verbname[, table args] )
  • object moo.find( string objectname )
  • variant moo.cookie( string name )
  • nil moo.set_cookie( string name, variant v )
  • nil moo.clear( string name )
  • bool moo.is_valid_object( object o )
  • nil moo.gmcp( string package, variant v )

Objects

Static functions

  • object moo.create()
  • object moo.create( object parent )
  • object moo.create( object parent, object owner )

Object methods

  • nil aliasadd( string alias )
  • nil aliasdel( string alias )
  • object child( string name )
  • {object} children()
  • verb verb( string name )
  • property prop( string name )
  • nil propadd( string name, variant v )
  • nil propdel( string name )
  • nil propclr( string name )
  • verb verbadd( string name )
  • nil verbdel( string name )
  • nil notify( string message )
  • {object} players()
  • {property} props()
  • {verb} verbs()
  • {object} find( string name )
  • bool is_child_of( object o )
  • bool is_parent_of( object o )
  • bool is_valid()

Object fields

  • int id
  • {string} aliases
  • string name
  • object owner
  • object parent
  • object location
  • connection connection
  • {object} contents
  • object player
  • bool programmer
  • bool wizard
  • bool read
  • bool write
  • bool fertile

Properties

Property methods

  • nil dump()
  • nil program()
  • nil edit()
  • variant value()

Property fields

  • string name
  • object owner
  • bool read
  • bool write
  • bool change

Verbs

Verb methods

  • nil aliasadd( string alias )
  • nil aliasdel( string alias )
  • nil dump()
  • nil program()
  • nil edit()

Verb fields

  • string name
  • {string} aliases
  • object owner
  • bool read
  • bool write
  • bool execute
  • string script
  • string dobj
  • string iobj
  • string preposition

Tasks

Static functions

  • int moo.task( int when, string code )
  • bool moo.kill( int taskid )

Connections

Static functions

  • connection moo.connection( int )
  • {connection} moo.connections()

Connection methods

  • nil notify( string )
  • nil boot( string )
  • object player()

JSON parsing

Static functions

  • json moo.parse( string s )

json methods

  • bool is_object()
  • bool is_array()
  • table pairs()
  • table array()
  • table object()

Open Sound Control (OSC)

Static functions

  • nil moo.oscsend( string address, ... )

Serial Ports

Static functions

  • serialport moo.open_serial_port( string name )
  • serialport moo.serial_port( int index )

serialport methods

  • nil set_baud_rate( int baudrate )
  • bool open()
  • nil close()
  • string read()
  • int write( string data )

serialport fields

  • int id

SMTP Mail Transport

Static functions

  • email moo.email()

Email methods

  • nil set_sender( string address )
  • nil set_sender( string address, string name )
  • nil add_text( string text )
  • nil add_to( string address )
  • nil add_to( string address, string name )
  • nil send()