Module object

Functions for object instances

Global functions

Object.invoke (vnum) create an instance of an object.

Class Object

object:contents () get an iterator over objects inside this one
object:echo (message, args) send a message to the occupants of the room the object is in.
object:getBlueprint () return the object's blueprint string
object:getCarriedBy () get the character holding this object.
object:getExtraDesc (the) return an extradesc on the object, or nil
object:getInObject () get the object directly containing this object.
object:getInRoom () get the room containing this object.
object:getLongDescription () return the object's long description.
object:getName () return the object's name (keywords).
object:getQty () return the object stack's quantity (or count)
object:getShortDescription () return the object's short description.
object:getType () return the object's type
object:getVNum () return the object's vnum
object:getValue0 () get the value0 for this object.
object:getValue1 () get the value1 for this object.
object:getValue2 () get the value2 for this object.
object:getValue3 () get the value3 for this object.
object:getValue4 () get the value4 for this object.
object:getValue5 () get the value5 for this object.
object:getVar (varName, default) get an object's variable by name
object:getVarTimer (varName) get the remaining time on an object's variable, by name
object:getWeight () get the object's weight.
object:hasFlag (flag) get whether a flag is set on this object.
object:hasWearloc (wearloc) get whether a wearloc is set on this object.
object:isOnGround () get whether the object is directly on the ground.
object:isStack () check if the object is a stack or a single instance
object:purge () Extracts the object.
object:setBlueprint (blueprint) set the blueprint string on an object
object:setExtraDesc (the) set an extradesc on an object
object:setFlag (flag, value) set a flag on this object.
object:setLongDescription (long) set the object's long description.
object:setName (name) set the object's name (keywords).
object:setShortDescription (short) set the object's short description.
object:setType (type) set the object's type
object:setValue0 (value) set the value0 for this object.
object:setValue1 (value) set the value0 for this object.
object:setValue2 (value) set the value0 for this object.
object:setValue3 (value) set the value0 for this object.
object:setValue4 (value) set the value0 for this object.
object:setValue5 (value) set the value0 for this object.
object:setVar (varName, value, ttl) set a variable on an object
object:setWearloc (wearloc, value) set a wearloc on this object.
object:setWeight (weight) set the object's weight.
object:toChar (ch) send an object to the given character.
object:toObject (target) put an object inside the given target object.
object:toRoom (room) send an object to the given room on the ground.


Global functions

Object.invoke (vnum)
create an instance of an object.

Parameters:

  • vnum number the object vnum

Returns:

    Object the new object

Usage:

  • -- invoke object 10000 and give it to a character
    Object.invoke(10000):toChar(self)
  • -- invoke object 1234 and do a few things with it
    local newObj = Object.invoke(1234)
    newObj:toChar(self)
    newObj:echo("{1} appears in your hands out of nowhere!", newObj)

Class Object

Functions on object variables
object:contents ()
get an iterator over objects inside this one

Returns:

    an iterator of Object

Usage:

    for obj in self:contents() do
      -- do something
    end
object:echo (message, args)
send a message to the occupants of the room the object is in. This will do nothing if the object is inside a container, but works if the object is on a character's inventory, equipped, or in a room.

Parameters:

  • message string the message to send. Can contain tokens referring to subsequent arguments, substituted appropriately for viewers.
  • args any any number of arguments corresponding to the {#} tokens in the message. {1} will refer to the first arg, etc.

Usage:

    self:onSpeech("activate", function(self)
      local ch = self:getCarriedBy()
      if ch then
        self:echo("{1} in {2.'s} inventory begins humming softly.", self, ch)
      else
        self:echo("{1} begins humming softly on the ground.", self)
      end
    end)
object:getBlueprint ()
return the object's blueprint string

Returns:

    string the object's blueprint string
object:getCarriedBy ()
get the character holding this object.

Returns:

    Character the character holding this object. Will be nil if it's on the ground or in any container.
object:getExtraDesc (the)
return an extradesc on the object, or nil

Parameters:

  • the string key of the extradesc to get

Returns:

    string the extradesc or nil
object:getInObject ()
get the object directly containing this object.

Returns:

    Object the object containing this object, or nil if it's in someone's inventory, worn, or on the ground.
object:getInRoom ()
get the room containing this object. Will work even if it's in a container or carried by someone.

Returns:

    Room the room containing this object.
object:getLongDescription ()
return the object's long description.

Returns:

    string the object's long description
object:getName ()
return the object's name (keywords).

Returns:

    string the object's name (keywords)
object:getQty ()
return the object stack's quantity (or count)

Returns:

    integer the object stack's quantity
object:getShortDescription ()
return the object's short description.

Returns:

    string the object's short description
object:getType ()
return the object's type

Returns:

    string the object's type
object:getVNum ()
return the object's vnum

Returns:

    integer the object's vnum
object:getValue0 ()
get the value0 for this object.

Returns:

    integer the current value0
object:getValue1 ()
get the value1 for this object.

Returns:

    integer the current value1
object:getValue2 ()
get the value2 for this object.

Returns:

    integer the current value2
object:getValue3 ()
get the value3 for this object.

Returns:

    integer the current value3
object:getValue4 ()
get the value4 for this object.

Returns:

    integer the current value4
object:getValue5 ()
get the value5 for this object.

Returns:

    integer the current value5
object:getVar (varName, default)
get an object's variable by name

Parameters:

  • varName string the name of the variable to get
  • default an optional default value (string, number, or boolean) to return if the variable is unset

Returns:

    the value, or the default or nil if it's not set. Can be a bool, number, or string.
object:getVarTimer (varName)
get the remaining time on an object's variable, by name

Parameters:

  • varName string the name of the variable whose timer you want to get

Returns:

    the integer value of seconds remaining in the timer, or 0 if it's expired, or nil if the variable is not set.
object:getWeight ()
get the object's weight.

Returns:

    integer the object's weight
object:hasFlag (flag)
get whether a flag is set on this object.

Parameters:

  • flag string The flag to check for

Returns:

    boolean True if the flag is set, false otherwise

Usage:

    if obj:hasFlag("antigood") do
      ch:echoAt("The cube glows red and zaps you!")
    end
object:hasWearloc (wearloc)
get whether a wearloc is set on this object.

Parameters:

  • wearloc string The wearloc name to check for

Returns:

    boolean True if the wearloc is set, false otherwise

Usage:

    if obj:hasWearloc("finger") do
      ch:echoAt("You think this would fit on your finger.")
    end
object:isOnGround ()
get whether the object is directly on the ground.

Returns:

    boolean true if the object is directly on the ground, false if carried or in an object.
object:isStack ()
check if the object is a stack or a single instance

Returns:

    boolean true if stack of objects or false if not
object:purge ()
Extracts the object.
object:setBlueprint (blueprint)
set the blueprint string on an object

Parameters:

  • blueprint string the new blueprint string
object:setExtraDesc (the)
set an extradesc on an object

Parameters:

  • the string key of the extradesc to set

Returns:

    string the extradesc to set
object:setFlag (flag, value)
set a flag on this object.

Parameters:

  • flag string The flag to set
  • value boolean The new value to set

Usage:

    obj:setFlag("antigood", true)
object:setLongDescription (long)
set the object's long description.

Parameters:

  • long string The new long description
object:setName (name)
set the object's name (keywords).

Parameters:

  • name string The new name (keywords)
object:setShortDescription (short)
set the object's short description.

Parameters:

  • short string The new short description
object:setType (type)
set the object's type

Parameters:

  • type string the new type
object:setValue0 (value)
set the value0 for this object.

Parameters:

  • value number the new value0
object:setValue1 (value)
set the value0 for this object.

Parameters:

  • value number the new value1
object:setValue2 (value)
set the value0 for this object.

Parameters:

  • value number the new value2
object:setValue3 (value)
set the value0 for this object.

Parameters:

  • value number the new value3
object:setValue4 (value)
set the value0 for this object.

Parameters:

  • value number the new value4
object:setValue5 (value)
set the value0 for this object.

Parameters:

  • value number the new value5
object:setVar (varName, value, ttl)
set a variable on an object

Parameters:

  • varName string the name of the variable to set
  • value the value, a string, number, or boolean. Pass in nil here to remove a variable.
  • ttl number the number of seconds to keep the variable, in seconds. (optional, if not specified it's kept indefinitely)

Usage:

    -- Set timesDropped to 1 more than the last value, handling the case where
    -- it hasn't been set yet by using 0 as the default
    obj:setVar("timesDropped", obj:getVar("timesDropped", 0)+1)
object:setWearloc (wearloc, value)
set a wearloc on this object.

Parameters:

  • wearloc string The wearloc to set
  • value boolean The new value to set

Usage:

    obj:setWearloc("finger", true)
object:setWeight (weight)
set the object's weight.

Parameters:

  • weight integer The new weight
object:toChar (ch)
send an object to the given character. This will remove it from wherever it currently is, whether in a container, on the ground, or carried by someone else.

Parameters:

  • ch Character The character to send the object to

Usage:

    Object.invoke(12345):toChar(someCharacter)
object:toObject (target)
put an object inside the given target object.

Parameters:

  • target Object The object instance to put the object in

Usage:

    Object.invoke(12345):toObject(backpack)
object:toRoom (room)
send an object to the given room on the ground. This will remove it from wherever it currently is, whether in a container, on the ground, or carried by someone else.

Parameters:

  • room Room The room to send the object to (can be a room variable or the vnum)

Usage:

  • Object.invoke(12345):toRoom(someRoom)
  • obj:toRoom(4)
generated by LDoc 1.5.0 Last updated 2024-10-22 16:05:00