The purpose of regions is to allow rooms to share common code - for instance, making ego swim whenever he steps into a lake (used in the beach scenes in Codename: Iceman) , or (as in SQ4) having droids/cyborgs/cops etc. appear in certain scenes.
A region that performs the countdown in your game would look like:
(script 700)
(include "game.sh")
(use "game")
(use "obj")
(use "main")
(use "controls")
(instance public TimeoutRegion of Rgn
(properties)
(method (newRoom room)
(= keep /* When ego leaves the region, this flag gets set to zero *(
(EqualsAny(room /* These rooms comprise the TimeoutRegion */
1 2 3 4 5 6 7)))
(super:newRoom(room))
)
(method (handleEvent event)
/* Put region-specific Said handling here */
(super:handleEvent(event))
)
(method (doit)
(var dyingScript)
(if(> gTimeMinutes C64die)
= dyingScript ScriptID(DYING_SCRIPT)
(send dyingScript:
caller(scriptNumber))
Print("The time is run out. It's too late to save your beloved computer Commodore 64. "+
"You must be quicker next time.")
(send dyingScript:
register("Game over! Thank you for playing \"DG: I want my C64 back\"."))
(self:dispose()) /* This avoids infinite loops */
(send gGame:setScript(dyingScript))
))
)
Then you add (self:setRegions(700)) to the relevant rooms, and remove the timeout code from them.
However, there is an implementation detail about regions that you may want to fix before you use this; for some reason, Sierra chose to remove all regions (also those that should be kept) - I don't know if this is a design decision or a bug, but all the games that I have looked at implement regions in this way. To make it easier to manage the code, the keep flag should be respected. To change this, open game.sc, and find the following chunk of code:
(send gRegions:
eachElementDo(#perform DNKR)
release(
)
Remove the call to release(), but leave the rest. Regions are now disposed of if the new room is outside the region. Thus, we only need to do the setRegions() thing in one room
Of course, if the rooms in the region are not adjacent, you will need to enable the region manually in every non-adjacent room. This also applies if the player can enter any room of the region, as opposed to being forced to enter through one specific room (which might be the case in games with a very linear storyline, for example) - in that case, this fix is somewhat redundant.