Transactions: Difference between revisions

From HLKitWiki
Jump to navigationJump to search
 
(One intermediate revision by the same user not shown)
Line 15: Line 15:
== Buying an Item ==
== 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.
A [[TransactBuy Script]] is invoked at two points:


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.
# When you add an item of gear that is not customized (i.e. it does not have a gizmo with a form associated with it, or the form is not shown because the "Customize" button was not pressed)


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.
# When you click "OK" on the gizmo form of an item of gear that was just added.
 
At these points, the [[TransactBuy Script]] runs. The script chosen is the one for the component on which the table through which the item was added 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.
 
Also, 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.


== Selling an Item ==
== Selling an Item ==
Line 26: Line 32:


After the script runs, the pick is deleted.
After the script runs, the pick is deleted.
== Transaction Pick Characteristics ==
It's important to note that the transaction pick can persist through multiple evaluations. For example, if you change anything on the "Sell Item" form, this triggers a re-evaluation. As part of a re-evaluation, all tags and fields are reset to their default values. This includes tags and fields on the transaction pick!
This means that to store information on the transaction pick, you need to use persistent fields or user fields. All normal fields will be reset to their defaults after every evaluation; any tags you add will be removed after each evaluation. The only information that is preserved is stored in user fields or persistent fields, just like with a regular pick.

Latest revision as of 17:05, 8 March 2011

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

A TransactBuy Script is invoked at two points:

  1. When you add an item of gear that is not customized (i.e. it does not have a gizmo with a form associated with it, or the form is not shown because the "Customize" button was not pressed)
  1. When you click "OK" on the gizmo form of an item of gear that was just added.

At these points, the TransactBuy Script runs. The script chosen is the one for the component on which the table through which the item was added 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.

Also, 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.

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.

Transaction Pick Characteristics

It's important to note that the transaction pick can persist through multiple evaluations. For example, if you change anything on the "Sell Item" form, this triggers a re-evaluation. As part of a re-evaluation, all tags and fields are reset to their default values. This includes tags and fields on the transaction pick!

This means that to store information on the transaction pick, you need to use persistent fields or user fields. All normal fields will be reset to their defaults after every evaluation; any tags you add will be removed after each evaluation. The only information that is preserved is stored in user fields or persistent fields, just like with a regular pick.