A shop generally works as follows:
- Articles are on display in alcoves of the shop. Each
article has a price.
- The player is free to pick up articles, and put them back into
any of the alcoves.
- There are cash receptacles (probably coin slots) that take
various denomination of coins.
- Articles can be placed
in any of the display alcoves for credit.
- There is a 'Lost and Found' alcove to receive any unknown item
types so that the player can retrieve them.
- Articles placed in the Lost and Found simply sit there.
They contribute no value.
- The shop has a door that remains closed until the player has paid
for all articles removed
- When the player successfully leaves the shop, all the articles in
the shop are sorted into their proper places.
- A shop has a bank which keeps track of articles removed and money
- A single 'virtual' shop can have several shopping areas with a
- A dungeon can have several 'virtual' shops, each with its own
A shop consists of:
- One or more areas of the dungeon which can be isolated by doors,
pits, teleporters, or whatever. These barriers are needed to
prevent the player from exiting the shop without paying.
- Zero or more 'Display Windows'. These are alcoves built in
solid walls that display the items for sale. The player can pick
up the items, examine them, put them back or pay for them and keep them.
- Zero or more 'Garbage Disposals'. These are used to dispose
of articles that have a trade-in value but which are not put on display
for resale. For example, you might want to accept Screamer Slices
as payment but you don't want an infinite number of them to pile up
because it would eventually crash the system.
- Zero or more 'Cash Slots'. Where the player can put money
to pay for articles purchased.
- Exactly one 'Lost and Found' alcove. When the player leaves
the shop any articles left behind that the shop does not handle will be
placed here. Also, at the same time, a tally is made of the total
value of all items remaining in the shop and all cash accepted.
If this total is too small, then the player is trying to steal
something and the barrier to exit is put in place. Any articles
places in the Lost and Found by the player will stay there until the
player retrieves them and have no value, even if the shop buys and
sells such articles.
- One or more 'Shop Exit' pressure pads. These should be
placed such that the player cannot see any of the 'Display Windows' or
'Lost and Found'. They should also be placed such that the player
cannot somehow remove objects from the shop without activating the
pressure pad. If, for example, the player could throw objects
through the exit door then it might be impossible to continue the game
if he did not have enough money to pay for the object. This
pressure pad also re-initializes the shop and sorts articles into their
proper 'Display Windows'.
Setting things up. Phase one. Placing actuators.
The Shop. Create one or more areas of the dungeon to be the
shops.'Display Windows'. As you prceed to place the alcoves,
DSAs, and other objects you should write on a piece of paper the type
and location (including position within the cell) of everything you
place. This will make Phase Two of the setup much easier.
'Display Windows'. In the walls of the shop area, place
alcoves. Each alcove can handle zero or more of only one type of
'Garbage Disposals'. These are placed where the player cannot see
them. Probably in some solid wall somewhere.
- Place one of the objects to be handled in the same cell as the
alcove but on the opposite side of the cell.. This object
determines the type of object the alcove will handle. If you
leave this empty then this Display Window will never contain
anything. But it might still be useful as a 'Returns/Trade-in'
window for articles that you accept as payment but not for sale.
- Then place as many as you please of the same type of object in
the alcove itself. Notice that this means you cannot have a
single cell column with 'Display Windows' on the four sides. But
you could have a four-cell column with eight alcoves.
- Place a 'Display Window' DSA in the cell on the same side as the
alcove. Set parameter A of the DSA to the price of the article.
'Cash Slots'. Probably placed one step prior to the 'Exit Pad'
- Put one object of the type to be disposed of in the same
cell. This will determine the type of object to be disposed of.
- Put a 'Garbage Disposal' DSA in the same cell. Set
parameter A of the DSA to the article's price.
- Place a 'More Parameters' DSA in exactly the same location.
'Lost and Found'. You need EXACTLY one of these per 'Virtual
Shop'. It does all the work of counting money, etc. It
serves as the 'Shopkeeper'.
- Place one pushbutton actuator for each type of coin, gem,
key, or whatever you want to accept as cash payment. Set the
pushbutton to 'Remove Object From Hand'. Set the Action to
'Holding Special Object' / 'Set'.
- Somewhere nearby, add an 'Accept Cash' DSA for each of the
pushbuttons. Set parameter A to the value of the particular
article that will actuate it. At the same location you must place
a "More Parameters' DSA to provde a space to keep track of the total
amount of cash accepted.
- Set the target of each pushbutton to the appropriate 'Accept
Cash' DSA. Set 'Position' to 'North'.
'Entrance/Exit' Pad. You need one of these inside the
entrance/exit of each physical shopping area. It should be placed
where it cannot see any of the 'Display Windows', the 'Lost and Found'
alcove, and should not be in a place where articles could be thrown out
of the shopping area prior to stepping on this pad. The player
must step on this pad before leaving the shopping area. If the
exit is blocked by a door then the door must be far enough from this
pad to prevent the player from running through the door as it is
- Place an alcove somewhere within the shop not visible from the
- Place a 'Lost and Found' DSA at the same location as the
alcove. Set parameter A to 'Integer'. Set value of
parameter A to zero.
- Place a 'More Parameters' DSA at the exact same location.
- Place pressure pad at appropriate place near shopping area
exit. Set 'Operated by' to 'Party Steps on Pad'.
- Set the target of this pressure pad to the 'Lost and Found' DSA
that you planted in the previous step and position North
- Set the 'Message Sent when Party Steps on Pad' to 'Set'.
- Clear 'Once Only'.
- You can choose the graphic and sound however you please.
Setting things up. Phase Two. Linking the shop together.
The shop works by passing messages around a 'ring' of DSAs. All
the 'Display Window', 'Garbage Disposal', 'Cash Slots', and 'Lost and
Found' DSAs are linked together using Parameter B of each to point to
the next. The 'Lost and Found' receives all messages initially
and acts as the 'Shop Keeper'. It processes any messages and, if
necessary, sends a message to the next DSA in the ring.
Eventually, the message will go around the entire ring and come back to
the 'Lost and Found' where it may or may not initiate another message
to the rest of the ring.
Go through the list of DSAs that you created in Phase One:
Link the 'Lost and Found' back to your door/pit/teleporter or other
method of keeping the player from leaving without paying.
Parameter D of the 'Lost and Found' should be set to the location that
is to receive the open and close messages. (This is Parameter B of the
'More Parameters' DSA that is at the same location of the 'Lost and
- Set Parameter B to type 'Target'
- Set Parameter B 'Level', 'Column', and 'Row' to the location of
the next DSA in your list. The last one should point to the first
- Set Parameter B 'Position' to the location within the cell of the
next DSA. This is important.
Now we need to provide a global variable for all the shop DSAs to
share. Having this global variable makes the whole business (pun
intended) easier to program and more efficient at runtime.
Multiple shops can share the same global variable. By default
this is variable number 14. If this
variable number conflicts with a global variable already in use then
can change it by editing each of the DSA types and changing the value
in the S0 and C0 lines of state number 15. For now we will assume
it is 14.
- In CSBuild, go to 'Edit/Global Info'.
- Click on 'Edit Databases'.
- Select 'Database Type' = 'Global Variables'.
- Select 'Global Variable Numbers' = '0-15'.
- Set Size = 16
- Click 'Read Record'. If it says 'No Such Record' then put
'0' in each data slot and Click 'Write Record'
- Click 'All Done'
How things work. Messages
- S0 - Used to initiate actions from external switches and
such to the 'Lost and Found' and to the 'Accept Cash' DSAs. Sent
to the Exit Door to open the door.
- C0 - Sent to the Exit Door to close the door.
- T0 -
- S1 -
- C1 -
- T1 -
- S2 -
- C2 -
- T2 - Check Payment. The global variable is cleared by 'Lost
and Found'. Then the Check Payment message is passed around the
ring. Each DSA adds the value of its contents to the global
variable. When the Check Payment message reaches the 'Lost and
Found', the total value is checked and a message is sent to open or
close the 'Exit Door'.
- S3 - Inventory Pass 1. The 'Display Windows', 'Garbage
Disposals', push unwanted articles forward around the ring. Turns
into an Inventory Pass 2 when it reaches the 'Lost and Found'.
- C3 - Inventory Pass 2. The 'Display Windows', 'Garbage
Disposals', push unwanted articles forward around the ring.
Turns into a 'Check Payment' message at 'Lost and Found'.
- T3 - Initialization. 'Lost and Found' passes this around
the ring and to the 'Exit Door' exactly once - the first time the shop
is entered. Terminates at 'Lost and Found'.
How things work. DSAs
All the DSAa in a shop are linked in a ring. Each is responsible
for maintaining and reporting the value of items in its
possession. Each is responsible for passing along messages and
any items it does not wish to keep track of. The 'Inventory'
messages, and unsorted items, are passed around the ring to get all the
items put into their proper places. Then a 'Payment' message is
passed around the ring and every DSA is expected to add the value of
its items to the Global Variable.
- The 'Accept Cash' DSA keeps no items. Everything given to
it is simply pushed onto the next DSA in the ring. Parameter C
contains the total value of all cash received. When it receives a 'T3'
message, it clears its parameter C. When it receives an 'S0'
message it adds Parameter A to Parameter C, assuming that you designed
the pushbutton to accept only coins of that value. When it
receives a 'T2' message it adds the value of all cash received
(Parameter C) to the Global Variable.
- The 'Display Window' DSA displays items for sale in its
associated alcove (or window). It is responsible for at most one
type of item. If it is responsible for zero types, then it serves
as a 'Returns/Tradein' window. When it receives 'Inventory'
messages (S3 or S2) it keeps any items for which it is responsible and
pushes any other items forward around the ring. When it receives
an 'Initialization' (T3) or 'Payment' (T2) message it adds the value of
all items in its possession the the Global Variable.
- The 'Garbage Disposal' DSA Deletes any items for which it is
responsible but keeps track of their value in Parameter C. When
it receives an Initialization message, it clears Parameter C.
When it receives Inventory messages, it keeps any items for which it is
responsible and pushes any other items forward around the ring.
When it receives a 'Payment' message, it deletes all the items in its
possession, add their value to Parameter C and then adds Parameter C to
the Global Variable.
- The 'Lost and Found' DSA is activated when the party enters or is
about to exit the shop. The very first time this happens, the
'Lost and Found' DSA sends an Initialization message around the ring to
determine the total value of all items originally in the shop.
The total value must always be the same or greater than the initial
value or else the door to the shop will close. The second and
subsequent activations of 'Lost and Found' do three things:
All of the DSAs have only one state - State 0. They all share a
common global variable. By default, variable 14. But they all use
state 15 as a 'configuration state' and the global variable number is
defined in only that one state to make it easier to change in case of
conflicts with other software. All the DSAs use parameter B to
locate the next DSA in the Shop's ring.
- Sort all the items. It first protects all items currently
in the 'Lost and Found' by sending them to the other side of the cell
where they are temporarily hidden. This is done to avoid the
possibility of having to move hundreds of items around the ring (
efficiency ) and to prevent items placed in the 'Lost and Found' by the
player from being added to the store's inventory. Then two
inventory messages are passed around the ring to push all items into
their proper locations. Then the temporarily hidden items are
moved back into view.
- The Global variable is cleared and a 'Payment' message is
passed around the ring to determine the total value of all items in the
store plus the total value of all cash received plus the total value of
all items accepted for value and disposed of.
- If the final value from step 2 is less than the value
determined when the party first entered the shop then the exit is
closed. Otherwise the exit is opened.
Here are some diagrams I drew before writing the DSAs. They are
very helpful in sorting out how the code fits together.