Graveyard Code

From Redwall MUCK Wiki


Feel free to use or adapt this if you want a cemetery in your building projects:

@dig Mossflower Woods: Graveyard==rw/graveyard

@dig Graveyard Offerings==rw/graveyard-offerings

@link #f $rw/graveyard=$rw/graveyard-offerings

@desc $rw/graveyard=--------------------------------------------------------------------\rDescription\r--------------------------------------------------------------------

@succ $rw/graveyard={lexec:user_stats}\r{lexec:graves}

@set $rw/graveyard=my_state:{default:{prop:visitor/{ref:me}/state},main}

@set $rw/graveyard=_depart/reset_state:},{store:{secs},visitor/{ref:me}/last_visit}}

lsedit $rw/graveyard=graves

.del ^ $

{escape}[36m

{lexec:{exec:my_state}}

{escape}[0m

.end

lsedit $rw/graveyard=user_stats

.del ^ $

{null:

{foreach:griever,

{contents:here},

{if:

{and:

{not:{dbeq:me,{&griever}}}

,

{or:{istype:{&griever},player},

{instr:{flags:{&griever}},Z}}},

{with:grave,

{prop:visitor/{ref:{&griever}}/grave},

{if:{&grave},

{store:1,tmp/bygrave/{&grave}/{ref:{&griever}}}}}}}}

{parse:grave,

{listprops:tmp/bygrave/},

{with:who,

{listprops:{&grave}},

- {commas:

{subst:{&who},{&grave}/,},

` and `,

p,

{name:{&p}}} {if:{eq:{count:{&who}},1},is,are} standing by a grave in row marked '{subst:{&grave},tmp/bygrave/,}'}}

{null:{delprop:tmp/}}

.end

lsedit $rw/graveyard=main

.del ^ $

You are standing by the edge of the graveyard. You may [enter] to pay your respects.\r

(See [grave help] for a full list of commands.)

.end

lsedit $rw/graveyard=grave help

.del ^ $

{list:help}

.end

lsedit $rw/graveyard=help

.del ^ $

Type: To:


- ENTER enter the graveyard

- ROW # enter row #

- ROWS show all the rows and the graves each contains

- APPROACH x approach a grave named 'x' in the current row

- NOTES view the notes on a grave

- ADD NOTE x leave a note by the current grave with the text 'x'

- LEAVE leave the graveyard

- ADD ROW x add a new row of graves with the name 'x'

- ADD GRAVE x add a new grave in your current row with the name 'x'

- CARVE x carve a permanent message into the grave you're beside


.end

lsedit $rw/graveyard=graveyard

.del ^ $

{with:row,{prop:visitor/{ref:me}/row},

{with:grave,{prop:visitor/{ref:me}/grave},

{if:{&row},

{if:{&grave},

You are standing by a gravestone marked: '{subst:{&grave},visitor/{ref:me}/grave,}'. It reads:\r

` `{prop:graves/{&row}/{&grave}}\r

{with:notes,

{listprops:graves/{&row}/{&grave}/notes},

{if:{&notes},

There {with:c,{count:{&notes}},{if:{eq:{&c},1},is a [note],are {&c} [note]s}} on the gravestone.}}

,

You are standing in row {&row}.` `

{with:dead,{listprops:graves/{&row}},

{if:{&dead},

You see the names of the dead:\r

{commas:{subst:{&dead},graves/{&row}/,}}\r

You may [approach] a gravestone to view it.

,

There are no gravestones in this row.}}}

,

You see {count:{listprops:graves/}} rows of graves. Use [row #] to enter one.\r

You may [leave] the graveyard.}}}

.end

@act enter;leave;approach;row;note;notes;add note;add grave;add row;carve;grave help;rows=$rw/graveyard=$rw/graveyard:act/enter=$nothing

@desc $rw/graveyard:act/enter={list:help,{loc:this}}

@succ $rw/graveyard:act/enter={lexec:{&cmd},{loc:this}}

lsedit $rw/graveyard=enter

.del ^ $

{if:

{eq:{exec:my_state},

main},

You enter the graveyard.

{null:

{store:graveyard,visitor/{ref:me}/state},

{otell:{name:me} enters the graveyard.}}

\r{lexec:graves}

,

You are already in the graveyard.}

.end

lsedit $rw/graveyard=leave

.del ^ $

{if:

{ne:{exec:my_state},

main},

You step to the edge of the graveyard.

{null:

{delprop:visitor/{ref:me}},

{otell:{name:me} steps to the edge of the graveyard.}}

\r{lexec:graves}

,

You have not entered the graveyard.}

.end

lsedit $rw/graveyard=row

.del ^ $

{if:{&arg},

{with:row,{prop:visitor/{ref:me}/row},

{if:{and:{eq:{&row},{&arg}},

{not:{prop:visitor/{ref:me}/grave}}},

You are already in row {&arg}.

,

{if:{prop:graves/{&arg}},

You walk respectfully to row {&arg} of the graveyard.

{null:

{delprop:visitor/{ref:me}/grave},

{store:{&arg},visitor/{ref:me}/row},

{store:graveyard,visitor/{ref:me}/state},

{otell:{name:me} walks respectfully to row {&arg} of graves.}}

\r{lexec:graves}

,

There is no row {&arg}. Choose a row #1-{count:{listprops:graves/}}.}}}

,

Which row do you want to enter? (1-{count:{listprops:graves/}})}

.end

lsedit $rw/graveyard=approach

.del ^ $

{if:{eq:{exec:my_state},graveyard},

{with:row,{prop:visitor/{ref:me}/row},

{if:{&row},

{with:matched,{sublist:{listprops:graves/{&row}/,this,{&arg}*},1,1},

{if:{&matched},

{with:grave,

{subst:

{&matched},graves/{&row}/,},

You approach the grave marked '{&grave}'.

{null:

{otell:{name:me} approaches the grave in row {&row} marked '{&grave}'.},

{store:{&grave},visitor/{ref:me}/grave}}}

\r{lexec:graves}

,

There is no grave with that name in this row.}}

,

You are not standing in a [row].}}

,

You are not standing in the graveyard. You must [enter] first.}

.end

lsedit $rw/graveyard=note

.del ^ $

{lexec:notes}

.end

lsedit $rw/graveyard=notes

.del ^ $

{with:grave,{prop:visitor/{ref:me}/grave},

{with:row,{prop:visitor/{ref:me}/row},

{if:{and:{&row},{&grave}},

{with:notes,{listprops:graves/{&row}/{&grave}/notes/},

{if:{&notes},

Near the grave marked '{&grave}'\, you see the following notes:\r

{parse:n,{&notes},- {prop:{&n}}}

,

There are no notes on this grave.}}\r

You can [add note ] to post a message by the grave.

,

You are not beside a grave.}}}

.end

lsedit $rw/graveyard=add note

.del ^ $

{with:grave,{prop:visitor/{ref:me}/grave},

{with:row,{prop:visitor/{ref:me}/row},

{if:{and:{&row},{&grave}},

{if:{&arg},

You add a note to the graveside: "{&arg}"

{null:{store:{&arg},graves/{&row}/{&grave}/notes/{secs}},

{otell:{name:me}\, standing beside a grave marked '{&grave}'\, adds a note.}}

,

What do you want your note to say?}

,

You are not beside a grave.}}}

.end

lsedit $rw/graveyard=add row

.del ^ $

{with:lastrow,{count:{listprops:graves}},

{if:{count:{listprops:graves/{&lastrow}/}},

{if:{set:arg,{strip:{&arg}}},

   		Graveyard: Added row #{inc:lastrow}
   		{null:{store:{&arg},graves/{&lastrow}}}
   	,
   	    Graveyard: Please provide a name for the new row.}

,

Graveyard: There are no graves in row #{&lastrow} yet.}}

.end

lsedit $rw/graveyard=carve

.del ^ $

{with:row,{prop:visitor/{ref:me}/row},

{with:grave,{prop:visitor/{ref:me}/grave},

{if:{and:{&row},{&grave}},

{if:{eq:{prop:graves/{&row}/{&grave}},` `},

Graveyard: Message set. (You cannot change this unless you speak to {name:{owner:this}}.)

{null:{store:{&arg},graves/{&row}/{&grave}}}

,

The message for that grave is already set.}

,

You are not standing by a grave.}}}

.end

lsedit $rw/graveyard=add grave

.del ^ $

{with:row,{prop:visitor/{ref:me}/row},

{if:{&row},

{if:{&arg},

{if:{le:{strlen:{set:arg,{strip:{&arg}}}},40},

Graveyard: Added grave '{&arg}' to row #{&row}.\rTo carve a message\, use [carve ].\r

YOU CAN ONLY CARVE A GRAVE ONCE.

{null:{store:` `,graves/{&row}/{&arg}},

{store:{&arg},visitor/{ref:me}/grave}}

,

That name is too long.}

,

You must give your grave a name. Example: add grave {name:me}}

,

You must be standing in the [row] where you wish to add the grave.}}

.end

lsedit $rw/graveyard=rows

.del ^ $

{parse:row,

   {listprops:graves},
   Row {subst:{&row},graves/,}: "{prop:{&row}}"\r
   {with:who,{listprops:{&row}/},
       {if:{&who},
           ` `{commas:{subst:{&who},{&row}/,}}
       ,
           ` `(empty)}}}

.end

@drop $rw/graveyard={lexec:dropped}

lsedit $rw/graveyard=dropped

.del ^ $

{with:row,{prop:visitor/{ref:me}/row},

{with:grave,{prop:visitor/{ref:me}/grave},

{if:

{and:{&row},{&grave}},

You set your offering down by the graveside.

{with:thing,

{sublist:{contents:{links:this},thing},1,1},

{null:

{otell:{pronouns:%n sets %p offering by the grave marked '{subst:{&grave},visitor/{ref:me}/grave,}'.}},

{store:{name:{&thing}},graves/{&row}/{&grave}/gifts/{&thing}}}}

,

Your offering is gobbled up by the Dark Forest.}}}

.end