Fireplace Tutorial

From Redwall MUCK Wiki

NMC Fireplace Demo - Active Object

Original by Otter

NMC update by Naco

When you light the fireplace it will start sending out random messages every few seconds or so. This is done by using {Delay} as a loop, in other words having a {delay}'ed command start the same delayed command again. This is limited because MPI only supports so many repetitions of things like {delay} before it stops automaticaly. But you can just start the fireplace back up again if it goes out.

You need to set the 'myobject' property at the bottom with the Database number of the fireplace; this ties all the functions together and is crucial to its operation. Though, it is not unchangeable. If you mess up you can reset it with the right number. If you want to add more messages you can add them under the 'Fire_descs' list at the bottom, they can be anything you want but they will not parse MPI.

@create Fireplace==NMCfiredemo

lsedit $NMCfiredemo=ldesc

.del 1 999

The fireplace is a well-built stone fireplace. There is plenty of wood and{lit: }

kindling nearby, if you wish to 'light' a fire. You can also 'feed' more{lit: }

wood to the fire to make it burn faster, or 'choke' it a bit by using the{lit: }

handy poker to seperate some of the fule. There is even sand to 'douse' the{lit: }

fire with when you are ready to leave.

.end

@desc $NMCfiredemo={lexec:ldesc}

+lock $NMCfiredemo=action=me&!me

+lock $NMCfiredemo=Force=Me

@set $NMCfiredemo=X

@force $NMCfiredemo=status #ic

+lock $NMCfiredemo=Force=$NMCfiredemo

@action douse;light;feed;choke=$NMCfiredemo

@link douse=$nothing

lsedit douse=light.cmd

.del 1 999

{if:

 {eq:{prop:islit},Yes},

 <> You're fireplace is already lit. <>,

 <> Lighting it now. <>

 {null:{otell:lights a fire in the fireplace. <> <>,here,#-1}}

 {null:{store:30,delaysecs}}

 {null:{store:Yes,islit}}

 {null:{store:{delay:{prop:delaysecs},{lit:{lexec:showfire}}},pid}}

}

.end

lsedit douse=douse.cmd

.del 1 999

{if:

 {eq:{prop:islit},Yes},

 <> You're fire is being carefully put out. <>

 {null:{kill:{prop:pid}}}

 {null:{otell:puts out the fire in the fireplace. <> <>,here,#-1}}

 {null:{store:No,islit}},

 <> There is no fire lit. <>

}

.end

lsedit douse=feed.cmd

.del 1 999

{if:

 {eq:{prop:islit},Yes},

 {if:

  {lt:{prop:delaysecs},5},

  <> That fire can't be made any larger! <>,

  {null:{otell:feeds the fire in the fireplace. <> <>,here,#-1}}

  {null:{store:{subt:{prop:delaysecs},3},delaysecs}}

  <> You've stoked even more wood into the fire. <>

 },

 <> There is no fire lit to feed more wood to. <>

}

.end

lsedit douse=choke.cmd

.del 1 999

{if:

 {eq:{prop:islit},Yes},

 {if: {gt:{prop:delaysecs},55},

  <> That fire can't be made any smaller! <>,

  {null:{otell:chokes the fire in the fireplace. <> <>,here,#-1}}

  {null:{store:{add:{prop:delaysecs},3},delaysecs}}

  <> You've further seperated the burning logs so the fire burns slower. <>

 },

 <> There is no fire lit to choke. <>

}

.end

lsedit douse=showfire

.del 1 999

{null:{force:{prop:myobject}, spoof {rand:fire_descs}}}

{null:{store:{delay:{prop:delaysecs},{lit:{lexec:showfire}}},pid}}

.end

lsedit douse=fire_descs

.del 1 999

The fire crackles merrily.

Inside the fireplace, the fire sputters a bit, and some sparks drift gently into the room.

A burning log shifts, causing a sharp crack.

The fireplace puts out a cheery glow.

Watch out! Some sparks shot out of the fireplace!

Smoke blows into the room from the fireplace as the wind outside shifts briefly.

.end

@succ douse={lexec:{&cmd}.cmd}

@osucc douse=pokes around the fireplace briefly.

drop fireplace

@set douse=myobject:#

See Also