Home
About
Policies
FAQ
Forums
Registration
Password Recovery

User:WhiteWizard/Lua API

From Tapestries MUCK

(Difference between revisions)
Jump to: navigation, search
(Database)
Line 31: Line 31:
* table d:timestamps() - keys: created, last_modified, last_used, use_count
* table d:timestamps() - keys: created, last_modified, last_used, use_count
* table d:stats() - Only works on players. Returns a table of # of objects owned by various types and total.
* table d:stats() - Only works on players. Returns a table of # of objects owned by various types and total.
-
* dbref d:link() what this is linked to.
+
* dbref d:link() what this is linked to.Alias to home for players/things
* nil d:set_link(dbref dest) link an object.
* nil d:set_link(dbref dest) link an object.
* nil d:unlink() - Unlink an object
* nil d:unlink() - Unlink an object
Line 39: Line 39:
* bool d:check_password(string password)
* bool d:check_password(string password)
* nil d:move(dbref destination)
* nil d:move(dbref destination)
-
* dbref d:location()
+
* dbref d:location() -- Alias to parent for rooms.
* array d:contents()
* array d:contents()
* array d:exits()
* array d:exits()
Line 52: Line 52:
* int d:con_time()
* int d:con_time()
* array d:owns()
* array d:owns()
-
 
+
* dbref d:create_(room|thing|exit)(string name)
 +
* dbref dbref.create_room(string name)
 +
* nil d:send_home()
==Locks==
==Locks==

Revision as of 23:07, 23 May 2013

This is a very quick definition of the (desired) API to access the Muck from Lua.

Contents

Database

Almost all database access is done through a lua class. In the examples, d refers to a dbref class instance.

  • string d:desc() - Return the description of the object.
  • nil d:set_desc(desc) - Set above.
  • string d:name() - Return the name of the object.
  • nil d:set_name(name, [password]) - Set the name. Password required for a player.
  • string d:unparse() - Returns the name in the long format that includes the dbref and flags.
  • integer d:type() - Returns the type of the object. One of: dbref.THING, dbref.PLAYER, dbref.GARBAGE, dbref.EXIT, dbref.ROOM
  • bool d.is_(thing|player|garbage|exit|room)() - Returns true if it is of this type.
  • bool d:is_valid() - Is > 0 < dbtop and not GARBAGE
  • string d:(success|osuccess|fail|ofail|drop|odrop)() - Get success/osuccess/fail/ofail/drop/odrop message.
  • nil d:set_(success|osuccess|fail|ofail|drop|odrop)(string) - Set success/osuccess/fail/ofail/drop/odrop message.
  • string|int|dbref|lock|nil d:get_prop(string name) - Returns the value of a property or nil.
  • nil d:set_prop(string name, string|int|dbref) - Set a property.
  • bool d:is_propdir(string name) - Is the given name a propdir?
  • nil d:remove_prop(stirng name) - Delete property if it exists.
  • string d:parse_prop(string name) - Parse a property with MPI and return a string.
  • table d:get_properties(nil | string base) - Starting at base, or /, get all the properties as a table.
  • string d:pronoun_sub(string source) - Only makes sense on a player object
  • nil d:set_flag(string flags)
  • string d:flags()
  • bool d:flag(string flag)
  • int d:get_mlevel()
  • int d:pennies()
  • nil d:set_pennies(int value) - Absolute, not relative.
  • nil d:add_pennies(int value) - Relative, negitive removes.
  • nil d:force(string command) - @force a player.
  • table d:timestamps() - keys: created, last_modified, last_used, use_count
  • table d:stats() - Only works on players. Returns a table of # of objects owned by various types and total.
  • dbref d:link() what this is linked to.Alias to home for players/things
  • nil d:set_link(dbref dest) link an object.
  • nil d:unlink() - Unlink an object
  • dbref d:owner()
  • nil d:set_owner(dbref player)
  • nil d:recycle()
  • bool d:check_password(string password)
  • nil d:move(dbref destination)
  • dbref d:location() -- Alias to parent for rooms.
  • array d:contents()
  • array d:exits()
  • bool d:is_locked(dbref player)
  • string d:lock_string()
  • nil d:set_lock_string()
  • lock d:parse_lock(string lock_expression)
  • nil d:clear_lock()
  • array d:connections()
  • bool d:is_awake()
  • int d:idle_time() - Lowest idle time from all connections.
  • int d:con_time()
  • array d:owns()
  • dbref d:create_(room|thing|exit)(string name)
  • dbref dbref.create_room(string name)
  • nil d:send_home()

Locks

  • bool lock:test(dbref player)
  • string lock:unparse()
  • string lock:pretty()

Globals

  • caller
  • me
  • trigger
  • program

Connection

c = a connection object

  • array connection.connections()
  • dbref c:player()
  • int c:idle()
  • nil c:boot()
  • int c:con_time()

Muck

  • string muck.version
  • string muck.name
  • string|int|bool muck.sys_param(string name)
  • string muck.timezone

Multitasking

Misc

  • string read() -- Yield until the player enters a string.
  • table require(string package) -- Follows the standard Lua package library stuff, but hacked to read from the Muck's registry and programs.
Personal tools
Namespaces
Variants
Actions
navagation
information
wiki
Toolbox