This shows you the differences between two versions of the page.
|
lua:scripting:examples:conservingvnums [2014/12/24 05:46] vodur created |
— (current) | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | In cases where multiple triggers are used for the same mob/object/area, it is possible to use a single prog for all the triggers. In the prog you can then have trigger specific code based on trigtype argument. | ||
| - | <code> | ||
| - | OBJPrograms for [31404]: | ||
| - | Number Vnum Trigger Phrase | ||
| - | ------ ---- ------- ------ | ||
| - | [ 0] 31400 drop 100 | ||
| - | [ 1] 31400 eat 100 | ||
| - | |||
| - | </code> | ||
| - | |||
| - | <code lua> | ||
| - | if trigtype=="eat" then | ||
| - | echo("You can't eat me!") | ||
| - | return false | ||
| - | elseif trigtype=="drop" then | ||
| - | echo("You can drop me.") | ||
| - | return true | ||
| - | end | ||
| - | </code> | ||
| - | |||
| - | <code> | ||
| - | eat cab | ||
| - | You can't eat me! | ||
| - | |||
| - | drop cab | ||
| - | You can drop me. | ||
| - | You drop Corned Beef and Cabbage. | ||
| - | </code> | ||
| - | |||
| - | If needed this could be taken one step further with the same prog being used for multiple mobs/objects/areas with vnum or name specific code sections. | ||