This is a script for a coin exchange system in...

March 15, 2023 at 07:31 PM

Scriptname DES_CoinExchanger extends ReferenceAlias FormList Property Coins Auto MiscObject Property Gold001 Auto Actor ref float value Event OnInit() addInventoryEventFilter(Coins) ref = getReference() as Actor value = 0.0 endEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) DES_CoinReplaceable coin = akBaseItem as DES_CoinReplaceable if(coin) int count = ref.getItemCount(coin) ; Debug.messageBox("Removing " + count + " " + coin.getName() + "s.") ref.removeItem(coin, count, true) value += coin.mult * count ; Debug.messageBox("Stored value: " + value + " gold.") count = value as int value -= count ; Debug.messageBox("Adding " + count + " gold. Stored value: " + value + " gold.") ref.addItem(Gold001, count, true) endIf EndEvent

This is a script for a coin exchange system in the game. The script listens to the inventory events of an object reference (Actor) and replaces any Coins added to the inventory with gold at a specific exchange rate. The exchange rate is defined by CoinReplaceable objects that have a "mult" property. Each time Coins are added to the inventory, the script removes them, calculates their value in gold, adds the value to a running total, and adds the equivalent amount of gold to the inventory.

Generate your own explanations
Download our vscode extension
Read other generated explanations

Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node