The following is an implementation of a cashier created for Dragan Lakic's project for a business education simulation. A vendor enters the prices for the products bought by the customer after which the cashier calculates the grand total. The customer then pays with money (made out of primitives) and the cashier takes the money (primitives delete themselves) and gives the customer the change.
The cashier and money system is created to simulate a real cashier system. It uses money primitives that are have special names that are processed by the key-value data system. This ensures a consistent communication between the money and the till.
One notable feature of the cashier is that it also implements a money system. In the examples below, a till was created as well as money bills for
1. Should the customer pay more than the required amount, the till effectively hands back the remainder, starting with the large bills and down to the smaller bills. Technically, this is performed by using insertion sort and handing out the largest bills first (as a polite teller would do).
The system however does not support sub-units since that would be more difficult to implement and unattractive from a code perspective. In either case, Linden-based worlds do not support sub-units and the lowest currency possible is the non-divisable value
Using named primitives in conjunction with the key-value data system, the system is not restricted to pre-defined money values. A user can implement their own money system and create bills with different values, provided that they name the money consistently.
1- excluding sub-units. When creating the bills, see the money section and give the bills the corresponding names. For example, a
50bill primitive will have its object name set to
money=50. Be sure to drop the money script into the bills as well since it will take care of removing (consuming) the money primitives.
It is interesting to note that this is one case where the permission system of the virtual world can be exploited to the build's advantage. For example, the money primitives could be set to transfer-only, so that once the customer rezzes the money and the till consumes them, then the customer will not have the original value in their inventory.