Object progs are the first to use the type of scripts the v3 mobprog system was truly designed for. Unlike all other trigger types, the Lua scripts called by object progs can return a value back to the MUD telling the MUD how to proceed with the requested action.
Compare this to a mobprog exit trigger. If the trigger fires at all, the standard MUD code to move the char is bypassed. If the trigger is not going to actually block the player's movement, the builder is left responsible for manualtimerly completing the movement - usually via a transfer call. It was necessary to convert this method for mobprogs because we had so many existing scripting relying on it - with object progs we get a fresh start.
From within any object prog, if the lua script returns a 'true' value to the MUD, the requested action is blocked. This leaves the actual task of dropping/getting/sacrificing an item in the core of the MUD code, where it belongs.
A couple of simple examples:
Returning true tells the MUD code itself to exit, do not complete the get or wield operation. If true is not returned, false is implied. Using the first prog above, if the player does have 300 or more str, the prog ends, false is returned and the MUD continues with the wear operation as usual.
Object Trigger Types
The actual syntax to add triggers to objects is the same as for rooms and mobs:
add type prog-id percent_chance [actor key]
All object trigger types so far take a percentage chance as their argument. If a mob key is included as an actor key, that mob must be present for the program to trigger. One example use of this is a more efficient way of having a guard mob preventing the player from taking a gem - put a "get" trigger on the gem requiring the guard as the actor. Have the guard perform the specific action, then return true to block the get operation.
The object trigger types available at the time of writing are listed below. This is just a small sample of the overall set for testing purposes. Note also that many luaprog commands still require an actor and do not work with object or room progs - these are being updated on the functions page as they are cleaned up. If you have a specific need for one in the meantime, contact Lasher.
Expire trigger example:
The second trigger is the expire trigger itself. The program makes sure that the item is still in a room and if so damages everyone in the room. See the item properties page for more information on some of the code below.