! The torch code here simulates the differences between a good torch, a ! burning torch, and one that has burned out. Having to count the ! number of torches in the game, then set that number here is a bit of a ! drag. Torch creation and removal is also rather clunky. ! ! Since you're dead if your torch goes out, checking to make sure we ! have one in hand before allowing one to be lit is superfluous. ! ! Later on: ! 1) determine how many moves a torch lasts before it goes out. ! 2) determine how many normal torches there are in the game. ! Class Torch with name "torch", power, parse_name [ i j w; if (parser_action == ##TheSame) { if ((parser_one.&name)-->0 == (parser_two.&name)-->0) { return -1; } return -2; } w = (self.&name)-->0; for (:: i++) { j = NextWord(); if (j == 'torches') parser_action=##PluralFound; else if (j~='torch' or w) return i; } ], daemon [ t newthing i; t = --(self.power); if (t == 0) { give self ~on ~light; newthing = DeadTorch.create(); give newthing moved; move newthing to parent(self); remove self; } if (self in player || self in location) { objectloop (i in player) { if (i ofclass BurningTorch) { if (i.power > TORCH_DECLINE) { rtrue; } } } if (t == TORCH_DECLINE + 1) { "^Your torch is beginning to flicker."; } if (t <= TORCH_DECLINE && t > TORCH_DYING) { "^Your torch is flickering and sputtering."; } if (t <= TORCH_DYING && t > 0) { "^Your torch is going out."; } if (t == 0) { "^Your torch goes out with a fizzle."; } } ], before [newthing; Smell: print "It smells like "; if (self ofclass UnlitTorch) "oil and dirt."; if (self ofclass BurningTorch) "burning oil and dirt."; if (self ofclass DeadTorch) "oily soot."; "Error in Torch class (Smell)^"; Examine: if (self ofclass UnlitTorch) "It's a torch. An oil-soaked rag is wrapped around it."; if (self ofclass DeadTorch) "It's a burned out and useless torch."; if (self ofclass BurningTorch) { print "The torch throws "; if (self.power < TORCH_DECLINE) { print "feeble"; } else { print "dancing"; } print " shadows about the "; if (parent(player) ofclass Outside) "place."; "room."; } "Error in Torch class (Examine)^"; Burn: if (second ~= nothing) { if (second hasnt on) "You can't burn ", (the) self, " with ", (the) second, "."; } if (self has on) "But it's already lit!"; <>; SwitchOff: if (verb_word == 'turn' or 'switch') "Perhaps snuffing the torch would be more useful."; if (self ofclass UnlitTorch or DeadTorch) "But it's not burning."; if (self ofclass BurningTorch) { newthing = DeadTorch.create(); move newthing to parent(self); give newthing moved; remove self; "You snuff out the torch."; } "Error in Torch class (SwitchOff)^"; ], after [newthing; Take: if (self hasnt moved) "You pull ", (the) noun, " off the wall."; SwitchOn: if (second == nothing) { give self ~on; "Perhaps lighting the torch with something would be more useful."; } if (self ofclass UnlitTorch) { newthing = BurningTorch.create(); if (newthing == nothing) { "Programming error! Can't light the torch."; } move newthing to parent(self); newthing.power = TORCH_LIFE + random(TORCH_VARIANCE); remove self; StartDaemon(newthing); "The torch burns brightly."; } if (self ofclass BurningTorch) "But it's already burning."; if (self ofclass DeadTorch) { give self ~on; "The dead torch sputters a bit, but refuses to light."; } "Error in Torch class (SwitchOn)^"; ], has switchable float; !Class UnlitTorch (TORCH_COUNT) Class UnlitTorch class Torch with name "unlit" "good" "torch", short_name "unlit torch", plural "unlit torches"; Class BurningTorch (TORCH_COUNT) class Torch with name "burning" "torch", short_name "burning torch", plural "burning torches", has on light; Class DeadTorch (TORCH_COUNT) class Torch with name "dead" "bad" "torch", short_name "dead torch", plural "dead torches";