by ralphmerridew » Thu Jun 23, 2011 4:00 pm
Outline of how to do the lamp:
You'll need two lamp objects (one for the dark lamp and one for the lit one).
The dark lamp should have two properties: "Battery_Life" (number) and "Is_on" (selection)
Battery_life should have a positive initial value. Is_on should be false. The dark lamp should be somewhere the player can find it and the lit one should be out of play.
Have an event that starts immediately, lasts one turn, restarts immediately on finish, and runs task "# Decrement Battery" on completion.
System task "# Decrement Battery".
It has one condition (Dark lamp has property is_on true).
It has two actions:
1) Decrease Battery_Life of dark_lamp by one.
2) Run task "# Check for exhausted lamp"
System task "# Check for exhausted lamp" has one condition (Battery_life of dark_lamp must be <= 0)
Actions are:
1) Run task "# Announce lamp going out"
2) Set Is_on of dark_lamp to false
3) Exchange locations of lit_lamp and dark_lamp.
4) Set Battery_life of dark_lamp to 0. (Sanity check)
System task "# Announce lamp going out" has one condition (lit_lamp must be visible to player)
It should print appropriate text.
Specific task "Turn on <dark_lamp>" with condition battery_life of dark_lamp > 0:
Print appropriate text.
Actions:
1) Set is_on of dark_lamp to true.
2) Exchange locations of dark_lamp and lit_lamp.
Specific task "Turn off <lit_lamp>"
Print appropriate text; set is_on to false; exchange locations.
Specific task "Turn on <dark_lamp>" with condition Battery_life <= 0.
Print appropriate text.
Specific task "Turn off <dark_lamp>"
Print appropriate text.
Specific task "Turn on <lit_lamp>".
Print appropriate text.
Optionally, add some system task like "# Announce low battery of xx", with two conditions (lit lamp visible to player and battery_life of dark_lamp == xx), that print appropriate text; have task "# Decrement battery" call them as well.
While I don't recommend the specific example of a lamp whose batteries run out, knowing how to manually implement timers is useful.
Bloodhounds can make you laugh and cuss in the same breath. They are endearing, faithful, and can sling drool ten feet in any direction. -- Virginia Lanier