Transactions

From HLKitWiki
Jump to navigationJump to search

A "transaction" takes place when the user adds certain game-system-dependent items of gear to the hero. It involves a TransactSetup Script, and either a TransactBuy Script or a TransactSell Script.

Setup

A TransactSetup Script is invoked at two points:

  1. When the user selects an item of gear on a choose form.
  1. When the user clicks the "delete" button for an item of gear.

Using this script, you can set up fields on the transaction pick. The transaction pick's fields hold information about the current transaction, before the transaction is executed.

For example, a common set of data for the transaction pick to hold is the buy or sell price of the current item. Before the user buys or sells the item, he can often change those values, which are then used in the TransactBuy Script or TransactSell Script.

Buying an Item

When you purchase an item, the TransactBuy Script runs. The script chosen is the one for the component on which the table is based. You can use this script to make changes to the hero, such as modifying the quantities of currency available in usage pools based on the buy price.

You can access the transaction pick from within the Creation Script for a component. This allows the user to modify fields on the transaction pick, which can then be checked from within the Creation Script as the pick is created. Using this method, you can configure fields on the new pick based on the settings on the transaction pick.

Note that when you buy something with an entity, and a "buy template" is specified for the gizmo form, the TransactBuy Script will not run until the user clicks "OK" on the gizmo form.

Selling an Item

When the user clicks "OK" on the "Are you sure you want to sell this item?" form, the TransactSell Script runs. This script can make changes to the hero, such as modifying the quantities of currency available in usage pools based on the sell price.

After the script runs, the pick is deleted.