Building: Plans/Timers
Plans are formatted like "0 command;5 another-command;0 another-command"
To start you get the object to execute "file_plan". This makes use of the plan in the "plan" property or, you use "file_plan fish" to use the plan in the "plan.fish" property.
The number is the number of seconds to wait.
If you want a plan to repeat, just call the appropriate file_plan at the end.
Plans can be put in temporary properties. file_plan !bang will look for the plan in "!plan.!bang". Plans now support string substitution tokens, so this is lesss necessary. (Use {} as a string substitution and file your plan with obj.file_plan_with_args).
command can be any command. Some commands behave specially when invoked as part of a trap. These are
- dockat - if no dock is available, it will block until one is
- route - if haven't arrived at destination yet (but it is possible to get to), will cause it to happen again next turn...
If you want to do more complex logic in one step of a plan, you may use the 'trap' verb,
which triggers the lua.trap
event handler directly. Trap takes an argument
so you may also do "trap blah" to run lua.trap.blah
Please remember that an object may only have one active timer/executing plan at a time.
Plans can be triggered in three ways. Firstly, a trap or a tell. Secondly, if you set the flag "StartPlan" on an object it will do file_plan whenever it is reset.
NB: If you want something to happen immediately after the doors open from a dockat, you should use the 'land' trap for it, as otherwise there is a delay of about 2 seconds between the doors opening and the next item in the plan executing.