Module object

Functions for object instances

Global functions

Object.all () iterate over all objects in the game
Object.invoke (vnum) create an instance of an object.

Class Object

object:addEffect (effectType, modifier) add an effect to an 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:effects () get an iterator over the object's effects
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:getWornBy () get the character wearing this object.
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:removeEffect (effectType, modifier) remove an effect from an object.
object:separate (qty) separates an object off the stack
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:stack () stacks an object and returns the stack
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.all ()
iterate over all objects in the game

Returns:

    an iterator of Object

Usage:

    for obj in Object.all() do
      -- do something
    end
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:addEffect (effectType, modifier)
add an effect to an object. Object must not be worn at the time.

Parameters:

  • effectType string the type of effect (hitpoints, wisdom, resistant, affected, etc)
  • modifier damage type or effect name for resistant/immune/susceptible/affected, numeric amount for anything else

Usage:

    obj:addEffect("strength", 3)
    obj:addEffect("affected", "sanctuary")
    obj:addEffect("resistant", "slash")
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:effects ()
get an iterator over the object's effects

Returns:

    an iterator of Effect

Usage:

    for obj in self:effects() do
      -- do something
    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:getWornBy ()
get the character wearing this object.

Returns:

    Character the character holding this object. Will be nil if it's not worn by a character.
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:removeEffect (effectType, modifier)
remove an effect from an object. Searches for an effect matching the given settings and removes the first one. If no such effect exists on the object, logs a warning but does not throw an error. Object must not be worn at the time, and must be an effect set on the instance itself, not the prototype.

Parameters:

  • effectType string the type of effect (hitpoints, wisdom, resistant, affected, etc)
  • modifier damage type or effect name for resistant/immune/susceptible/affected, numeric amount for anything else

Usage:

    obj:removeEffect("strength", 3)
object:separate (qty)
separates an object off the stack

Parameters:

  • qty integer the number of objects to separate off of the stack (optional, defaults to 1 if not specified)

Returns:

    Object the separated object (or object stack)
object:setBlueprint (blueprint)
set the blueprint string on an object

Parameters:

  • blueprint string the new blueprint string

Returns:

    Object the object, for call chaining
object:setExtraDesc (the)
set an extradesc on an object

Parameters:

  • the string key of 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

Returns:

    Object the object, for call chaining

Usage:

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

Parameters:

  • long string The new long description

Returns:

    Object the object, for call chaining
object:setName (name)
set the object's name (keywords).

Parameters:

  • name string The new name (keywords)

Returns:

    Object the object, for call chaining
object:setShortDescription (short)
set the object's short description.

Parameters:

  • short string The new short description

Returns:

    Object the object, for call chaining
object:setType (type)
set the object's type

Parameters:

  • type string the new type

Returns:

    Object the object, for call chaining
object:setValue0 (value)
set the value0 for this object.

Parameters:

  • value number the new value0

Returns:

    Object the object, for call chaining
object:setValue1 (value)
set the value0 for this object.

Parameters:

  • value number the new value1

Returns:

    Object the object, for call chaining
object:setValue2 (value)
set the value0 for this object.

Parameters:

  • value number the new value2

Returns:

    Object the object, for call chaining
object:setValue3 (value)
set the value0 for this object.

Parameters:

  • value number the new value3

Returns:

    Object the object, for call chaining
object:setValue4 (value)
set the value0 for this object.

Parameters:

  • value number the new value4

Returns:

    Object the object, for call chaining
object:setValue5 (value)
set the value0 for this object.

Parameters:

  • value number the new value5

Returns:

    Object the object, for call chaining
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

Returns:

    Object the object, for call chaining

Usage:

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

Parameters:

  • weight integer The new weight

Returns:

    Object the object, for call chaining
object:stack ()
stacks an object and returns the stack

Returns:

    Object the object stack
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

Returns:

    Object the object, for call chaining

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

Returns:

    Object the first object, for call chaining

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)

Returns:

    Object the object, for call chaining

Usage:

  • Object.invoke(12345):toRoom(someRoom)
  • obj:toRoom(4)
generated by LDoc 1.5.0 Last updated 2026-02-08 06:17:47