Abusing the Candle class

Some days ago, I mentioned a neat trick, abusing adv3’s Candle class for creating a volatile scent; I find interesting the code, so I think that is appropriate to share it, with hopefully clear commenting:

// abusing the poor candle class in an unusual manner
scent: Candle, Immovable 'volatile scent' 'scent'

// In the original, the scent is associated to a different thing... 
desc () {
  switch(fuelLevel) {
	case 0:
	 "the little sprayer whose has sprayed the volatile scent is closing"; 
	case 1: 
	 "the little sprayer is closed";
    case 2:
      "two case should be enough"; break; // seems not reached; rm this ?
	  "something got horribly wrong";
fuelLevel = 2
brightnessOn = 0 //scents don't gives light..
// of course, smellDesc can also be a switch(fuelLevel)....
smellDesc = "The volatile scent is of rose.."
// example of different senses.
tasteDesc = "you can't taste the volatile odor..."
  { "The scent dissipated totally";
    moveInto(nil); // the unthing seems unneeded, but see below...

// the unthing for the now-former scent
scentgone: Unthing 'rose scent' 'scent'
'The rose scent is no more around, \'twas extremely volatile, indeed.'

// testing the presence/absence of the "candle" and/or its unthing allows 
// referencing it in the relevant description/sense description, or even another
// smellDesc, e.g.:

roomodor : SimpleOdor 'room' 'odor' @relief
desc = "<<if scent.isIn(room)>> The odor from the sprayer is arond.
<<else if scentgone.isIn(room)>><<one of>>The scent from the sprayer is 
already gone: Clearly, was a very volatile odor.<<or>>The scent from the 
sprayer is already gone: Clearly, was a very volatile 
odor.<<or>>the scent is definitively gone<<stopping>>
<<else>>Here is the room's odor (or lack of..) prior of the spray 
isAmbient = true

Hope that this little trickery can be interesting, even useful…

Best regards from Italy,
dott. Piergiorgio.


Certainly creative! Sometimes those are the most fun kinds of achievements in personal code like this…