Lua Object Progs Enhancements - Test port.
Part of the reason for starting this blog was to give more detail on the background of things that will never be announced on the live port because they are “behind the scenes”. This post covers some changes to the Lua integration. If you’re not interested in the building / Lua side of the MUD, skip this post.
New Lua MUD function: getobj
The function ‘getobj’ works similar to getmob/getroom and can search in a room, on a character or inside another item. Full syntax with examples can be seen at:
Getobj Lua Function Documentation / Examples
New Object Properties available in Lua:
Property | Description |
obj.aname | Returns the object name with A/AN/THE on the front of the object name removed, but with color codes intact. Useful for constructing messages containing the object name without running into problems such as “The a long sword glows brightly.” |
obj.room | ROOM var if the item is in a room or NIL. |
obj.char | CH var if the item is on a character, or NIL. |
obj.inside | OBJ var if the item is in a container, or NIL. |
obj.root | The top level container if the item is insider another container. Returns a copy of itself if not in a container. |
obj.loctype | Used to check the type of location an item is in. See below for list of values. |
obj.loctype returns one of :
Value | Description |
OBJ_LOC_PLAYER | Object is on a player |
OBJ_LOC_MOB | Object is on a mob |
OBJ_LOC_ROOM | Object is in a room. |
OBJ_LOC_CONTAINER | Object is in a container. |
OBJ_LOC_NOWHERE | Object is nowhere (auction or bug) |
New Lua Object Trigger Type: Expire
There is a new object trigger type : ‘expire’. If an item has a timer, any Lua scripts attached to an expire trigger will be executed just before the item is removed from the game.
Most of these changes were added to make use of the expire trigger type. You need to be able to know where an item is when it expires to decide what to do. You might want an item to damage everyone in the room or blow up a door to the north (open it) when it expires, but need to know if it is actually in a room first. Another item may have an expire script that does something to a player holding it - before proceeding you need to be able to make sure the item is actually being carried by someone.
To see the infamous exploding pie triggers and how simple they are, check out the bottom of:
Lua MUD Object Prog Documentation
Please note that rawDamage is not yet tested or documented and should not be used until announced.