Trap for managing a single item that can be bought from an in-game store. Uses ScriptParams links to coordinate with the item being purchased, the store script, and an optional cart to hold the purchased items.
The item controlled by this script is linked using a ScriptParams link of type Item. If the Item is concrete, then the Engine Features\Stack Count is the total inventory that is available, and each purchase is always one item. If the Item is an archetype, then the store holds an unlimited supply and each purchase will give you the number of items in the Engine Features\Stack Count.
This trap is linked to the object with the ShoppingCart script using a ScriptParams link of type Store. The Trap\Quest Var property will be read from the store object. If a separate container is being used for purchased item, link to it using a ScriptParams link of type Cart. Without a Cart link, the Store object is used.
When turned on, the Item object is duplicated and added to the Cart container. The purchase price of the item is added to the quest variable for the Store. On TurnOff, the Item is subtracted (by Engine Features\Stack Count) from the Cart and the purchase price deducted from the quest variable. On Reset, it removes all of its items from the Cart.
|Messages||TurnOn, TurnOff, Reset|
|Links||ScriptParams(Cart), ScriptParams(Item), ScriptParams(Store)|
|Properties||Trap\Quest Var, Engine Features\Stack Count|