Skip to content

Redwall MUCK Site

Sections
Personal tools
You are here: Home » Members » Riverdale's Home » Code Examples » Soda Machine
« January 2009 »
Su Mo Tu We Th Fr Sa
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
 

Soda Machine

A simple MPI Soda Machine
@create Soda Machine

@lock soda machine=me

@desc Soda Machine={null:{tell:In the corner of the room rises the form of an ordinary soda machine. There {if:{eq:{count:choices,soda machine},1},is,are} {count:choices,soda machine} selection{if:{ne:{count:choices,soda machine},1},s} printed on enumerated buttons\, each displaying a separate soda name and a picture which makes one extraordinarily thirsty.\rThe selections are:\r}}{null:{foreach:soda,{exec:choices,soda machine},{tell:{&soda}) - {prop:{&soda},soda machine} {if:{eq:{prop:{&soda}num,soda machine},0}, - Sold Out}}}}To make your selection, simply type 'select <number of selection>'. For instance, to order a {prop:2,soda machine}, I would 'select 2' and, if that item was not sold out, it could come down the shoot. To check how many sodas are remaining in a certain slot type 'check <selection #>'. To look at the label for a selection, type 'lsoda <selection #>'.\r

@set Soda Machine=choices:1\r2\r3\r4\r5\r6\r7\r8\r9\r10

@set Soda Machine=1:Coca-Cola

@set Soda Machine=2:Pepsi

@set Soda Machine=3:Sprite

@set Soda Machine=4:7up

@set Soda Machine=5:Birch Beer

@set Soda Machine=6:Cherry Coke

@set Soda Machine=7:Fresca

@set Soda Machine=8:Cherry Bomb Jolt

@set Soda Machine=9:Surge

@set Soda Machine=10:Mountain Dew

@set Soda Machine=_cap:15

@set Soda Machine=1num:15

@set Soda Machine=2num:15

@set Soda Machine=3num:15

@set Soda Machine=4num:15

@set Soda Machine=5num:15

@set Soda Machine=6num:15

@set Soda Machine=7num:15

@set Soda Machine=8num:15

@set Soda Machine=9num:15

@set Soda Machine=10num:15

@set Soda Machine=sodadesc1:A small red button with the number '1' printed in the corner. The flowing words, written in white and silver, 'Enjoy Coca-Cola' are situated above an ice-cold bottle of Coke, beaded here and there with droplets of condensed moisture.

@set Soda Machine=sodadesc2:Blue and red dominate the button with the number '2' written lightly in the corner. The name 'Pepsi' stands saliently at the top.

@set Soda Machine=sodadesc3:The green and blue of the third button on the soda machine marks it as being the one for Sprite. The slogan 'Obey Your Thirst' appears at the bottom.

@set Soda Machine=sodadesc4:The fourth button displays the name '7up' and bears the slogan, 'Make 7 Up Yours'.

@set Soda Machine=sodadesc5:Classic Birch Beer.

@set Soda Machine=sodadesc6:A distinctive style of writing sets the button proclaiming 'Cherry Coke' apart from the others.

@set Soda Machine=sodadesc7:A button showing a picture of Fresca and grapefruits.

@set Soda Machine=sodadesc8:Mmm...Cherry Bomb Jolt

@set Soda Machine=sodadesc9:A button with the words 'Surge!" upon it.

@set Soda Machine=sodadesc10:A button numbered '10' with the words 'Do the Dew' written upon it below the name 'Mountain Dew'.

@act select=soda machine

@link select=$nothing

@act set=soda machine

@link set=$nothing

@act restock=soda machine

@link restock=$nothing

@act check=soda machine

@link check=$nothing

@act capacity=soda machine

@link capacity=$nothing

@act add=soda machine

@link add=$nothing

@act remove=soda machine

@link remove=$nothing

@act dsoda=soda machine

@link dsoda=$nothing

@act lsoda=soda machine

@link lsoda=$nothing

@lock set=me

@lock restock=me

@lock capacity=me

@lock add=me

@lock remove=me

@lock lsoda=me

@fail set=You cannot change the sodas without a key!

@fail restock=You cannot restock sodas without a key!

@fail add=You cannot add selections without a key!

@fail capacity=You cannot adjust the capacity of the soda machine without a key!

@fail dsoda=You cannot change the soda descriptions!

@fail remove=You cannot remove sodas without a key!

@succ set={if:{&arg},{if:{midstr:{&arg},1,{subt:{instr:{&arg},=},1}},{if:{subst:{midstr:{&arg},{add:{instr:{&arg},=},1},-1},=,},{if:{ne:{lmember:{exec:choices,soda machine},{midstr:{&arg},1,{subt:{instr:{&arg},=},1}}},0},You replace {prop:{midstr:{&arg},1,{subt:{instr:{&arg},=},1}},soda machine} with {midstr:{&arg},{add:{instr:{&arg},=},1},-1}.{null:{store:{midstr:{&arg},{add:{instr:{&arg},=},1},-1},{midstr:{&arg},1,{subt:{instr:{&arg},=},1}},soda machine},{otell:{name:me} replaces #{midstr:{&arg},1,{subt:{instr:{&arg},=},1}} with {midstr:{&arg},{add:{instr:{&arg},=},1},-1} in the soda machine.}},That is not a selection to replace!},Please supply something to put in place of {prop:{midstr:{&arg},1,{subt:{instr:{&arg},=},1}},soda machine}.},Please provide what you wish to replace.},You must supply an argument. (set <# of selection>=<replacement>).}

@succ restock={if:{&arg},{if:{ne:{lmember:{exec:choices,soda machine},{&arg}},0},{if:{lt:{prop:{&arg}num,soda machine},{prop:_cap,soda machine}},You restock {prop:{&arg},soda machine}. {null:{otell:{name:me} restocks {prop:{&arg},soda machine} on the soda machine.},{store:{prop:_cap,soda machine},{&arg}num,soda machine}},{prop:{&arg},soda machine} is full!},{if:{eq:{&arg},all},You restock all sodas. {null:{otell:{name:me} restocks all sodas.},{foreach:soda,{exec:choices,soda machine},{store:{prop:_cap,soda machine},{&soda}num,soda machine}}},That is not a section to restock!}},What do you wish to restock?}

@succ select={if:{&arg},{if:{ne:{lmember:{exec:choices,soda machine},{&arg}},0},You punch in your selection. {if:{ge:{prop:{&arg}num,soda machine},1},An ice-cold {prop:{&arg},soda machine} drops down. {null:{otell:{name:me} selects #{&arg} on the soda machine and an ice-cold {prop:{&arg},soda machine} drops down.},{store:{subt:{prop:{&arg}num,soda machine},1},{&arg}num,soda machine}},There are no {prop:{&arg},soda machine}s remaining. Please wait until someone restocks the soda machine before trying again. {null:{otell:{name:me} depresses the button for {prop:{&arg},soda machine}\, but that item is sold out.}}},That is not a selection!},What button do you wish to press?}

@succ capacity={if:{&arg},{if:{isnum:{&arg}},You set the capacity for the soda machine to {abs:{&arg}} soda{if:{ne:{abs:{&arg}},1},s}. {null:{store:{abs:{&arg}},_cap,soda machine},{foreach:soda,{exec:choices,soda machine},{if:{ge:{prop:{&soda}num,soda machine},{abs:{&arg}}},{store:{abs:{&arg}},{&soda}num,soda machine}}}},That is not a numerical value!},The current capacity per slot of the soda machine is {prop:_cap,soda machine}. To reset it\, use 'capacity <capacity>'.}

@succ check={if:{&arg},{if:{ne:{lmember:{exec:choices,soda machine},{&arg}},0},There {if:{eq:{prop:{&arg}num,soda machine},1},is,are} {if:{le:{prop:{&arg}num,soda machine},0},0,{prop:{&arg}num,soda machine}} {prop:{&arg},soda machine}{if:{ne:{prop:{&arg}num,soda machine},1},s} left in the soda machine. {null:{otell:{name:me} 'check's to see how many {prop:{&arg},soda machine}s are left in the soda machine.}},That is not a valid selection!},What do you wish to check for?}

@succ add=You add the selection #{add:{count:{exec:choices,soda machine}},1} to the soda machine. Now you should 'set <selection #>=<name>'.{null:{otell:{name:me} adds the selection #{add:{count:{exec:choices,soda machine}},1} to the soda machine.},{store:{exec:choices,soda machine}\r{add:{count:{exec:choices,soda machine}},1},choices,soda machine}}{if:{&arg},{null:{store:{&arg},{count:{exec:choices,soda machine}},soda machine},{otell:{name:me} sets the name of selection #{count:{exec:choices,soda machine}} to {&arg}.}} Name set to {&arg}.}

@succ remove=You remove selection #{count:{exec:choices,soda machine}} on the soda machine. {null:{otell:{name:me} removes selection #{count:{exec:choices,soda machine}} on the soda machine.},{delprop:{count:{exec:choices,soda machine}},soda machine},{delprop:{count:{exec:choices,soda machine}}num,soda machine},{delprop:sodadesc{count:{exec:choices,soda machine}},soda machine},{store:{subst:{exec:choices,soda machine},\r{count:{exec:choices,soda machine}},},choices,soda machine}}

@succ dsoda={if:{&arg},{if:{midstr:{&arg},1,{subt:{instr:{&arg},=},1}},{if:{subst:{midstr:{&arg},{instr:{&arg},=},-1},=,},{if:{ne:{lmember:{exec:choices,soda machine},{midstr:{&arg},1,{subt:{instr:{&arg},=},1}}},0},You set {prop:{midstr:{&arg},1,{subt:{instr:{&arg},=},1}},soda machine}'s description to:{midstr:{&arg},{add:{instr:{&arg},=},1},-1}{null:{store:{midstr:{&arg},{add:{instr:{&arg},=},1},-1},sodadesc{midstr:{&arg},1,{subt:{instr:{&arg},=},1}},soda machine}},That is not a selection to describe!},Description cleared. {null:{delprop:sodadesc{midstr:{&arg},1,{subt:{instr:{&arg},=},1}},soda machine}}},Please supply a selection whose description you wish to change.},Dsoda: Proper syntax: 'dsoda <selection #>=<description>'.}

@succ lsoda={if:{&arg},{if:{ne:{lmember:{exec:choices,soda machine},{&arg}},0},{if:{prop:sodadesc{&arg},soda machine},Description for {prop:{&arg},soda machine}:\r{exec:sodadesc{&arg},soda machine},No description for that label.},That is not a selection!}{null:{otell:{name:me} looks at the label for {prop:{&arg},soda machine} on the soda machine.}},You need to supply a selection # to look at (lsoda <selection #>).}
Created by Riverdale
Last modified 2006-12-27 07:43 PM
 

Powered by Plone

This site conforms to the following standards: