====== ObjProgs ====== Obj progs are attached in oedit with addoprog command. Obj progs are always lua scripts. ^Script Argument^Type^Note| |obj2|[[:lua:obj:members|OBJ]]|see table| |ch1|[[:lua:ch:members|CH]]|see table| |ch2|[[:lua:ch:members|CH]]|see table| |text1|string|see table| |trigger|string|see table| |trigtype|string|see table| The actual object to which the script is attached can be referenced in the script through '**obj**' global variable (type [[:lua:obj:members|OBJ]]). ^trigtype^obj2^ch1^ch2^text1^trigger^Phrase type^Description| |[[:triggers:oprog:give|give]]*|none|giver|receiver|none|none|number(%chance)| | |drop*|none|dropper|none|none|none|number(%chance)| | |eat*|none|eater|none|none|none|number(%chance)| | |drink*|none|drinker|none|none|none|number(%chance)| | |quaff*|none|eater|none|none|none|number(%chance)| | |sacrifice*|none|saccer|none|none|none|number(%chance)| | |wear*|none|wearer|none|none|none|number(%chance)| | |remove*|none|remover|none|none|none|number(%chance)| | |spell*|none|caster|none|none|spell name|string(spell name or *)|Triggers when the object itself is target of spell| |speech|none|speaker|none|none|full speech text|string(keyword or *)|If in inventory, fires on speech of character holding it, if in room, fires on speech of anyone in room| |try|none|tryer|none|none|full try text|string(phrase or *)|If in inventory, fires on try of character holding it, if in room, fires on try of anyone in room| |put*|container|putter|none|none|none|number(%chance)|oprog goes on the object that is being put, not a container.| |get*|container|getter|none|none|none|number(%chance)|oprog goes on the object that is being get, not a container.| |merge*|second object|merger|none|none|none|number(%chance)| \\ Triggers when object is merged. Return false to prevent the merge from completing. \\ \\ When player does a merge, the first object is checked for merge trigger and if it has one, its prog is run. If the first script returns false then the merge is canceled and the second object is not checked for merge trigger. If the first object didn't have a trigger or the prog returns true then the second object is checked for trigger prog is run if it has one. If the second trigger returns false then the merge is canceled, otherwise if it has no merge trigger or the prog returns true the the merge will succeed.| | rand| none| none| none| none| none| number(%chance)| Checks every tick| | greet| none| ch| none| none| none| number(%chance)| No vis check. \\ See [[:triggers:enterandexit|enter and exit triggers]].| | [[:triggers:oprog:look|look]]*| none| looker| none| none| look argument| string(phrase or *)| Triggered on look or examine| | lore*| none| lorer| none| none| none| number(%chance)| | |move*|none|mover|none|none|none|number(%chance)|Triggers when object is in the inventory or equipped by a player and the player moves. Return true allows movement, return false prevents it. \\ See [[:triggers:enterandexit|enter and exit triggers]].| |enter*|none|enterer|none|none|none|number(%chance)|When player enters the object (portal). \\ See [[:triggers:enterandexit|enter and exit triggers]].| |unlock*|none|unlocker|none|none|none|number(%chance)|When player unlocks an object (container only)| |open*|none|opener|none|none|none|number(%chance)|When player opens an object (container only)| |sit*|none|sitter|none|none|none|number(%chance)|When player sits on an object (furniture only)| |rest*|none|rester|none|none|none|number(%chance)|When player rests on an object (furniture only)| |sleep*|none|sleeper|none|none|none|number(%chance)|When player sleeps on an object (furniture only)| |wake*|none|waker|none|none|none|number(%chance)|When a player wakes/stands from sitting/resting/sleeping on object (furniture only)| |fight|none|wearer|enemy|none|none|number(%chance)|Checked every round of a fight. Only checked for worn/wielded items.| |death|none|killer|victim|none|none|number(%chance)|Triggers when object is in inventory or equipped by killer. Checked when victim is killed by the killer.| |prehit*|none|hitter|victim|none|damage|number(%chance)|Checked on weapon before successful hit.| |hit|none|hitter|victim|none|none|number(%chance)|Checks on weapon after successful hit (and after other effects such as weapon flag, stance, behead, etc). Checks on gloves when fighting unarmed.| |[[:triggers:timer|timer]]|none|none|none|none|none|number(seconds interval)|Fires at an interval of x seconds (provided as phrase)| |command|none|commander|none|command arguments|command name|string(command name)| | |(*)If trigger fires, command is prevented from going through unless 'return true' in the script.| \\