currency (like many things) should be done as~via attributes instead of trying to use actual objects for what you want to do.
you don't want to have actual~physical "gold_coin" objects as your currency, moving back and forth, instead you want to have a "virtual" currency, which is done by the attributes, which you then can adjust easily for your (again "virtual") transactions.
first, you need to have a "cash" amount:
Object -> Attributes (Tab) -> Add Attribute:
Object: player
Name: cash
Type: int (integer) or double // NOT as a String Type!
Value: 0 or 0.00 // or whatever you want for your starting amount
then your item objects need to have a "price" amount:
Object: wooden_sword
Name: price
Type: int or double
Value: 10 or 9.99 // or whatever you want for your item's price
now for the operator (addition, subtraction, multiplication, and division) expressions for attributes:
Add a script -> Variables -> Set a variable or attribute ->
(hopefully you can figure out how to set it up correctly in the GUI~Editor)
in code, it looks like this, for example:
player.cash = player.cash + 10
player.cash = player.cash - 10
player.cash = player.cash * 10
player.cash = player.cash / 10
How it works conceptually:
player.cash (intial amount) = 100
player.cash (new amount) = player.cash (old amount) + 10
player.cash = 100
player.cash = player.cash + 10
player.cash = 100 + 10
player.cash = 110
player.cash = player.cash - 10
player.cash = 100 - 10
player.cash = 90
player.cash = player.cash * 10
player.cash = 100 * 10
player.cash = 1,000
player.cash = player.cash / 10
player.cash = 100 / 10
player.cash = 10
and now for your "buy" verb:
wooden_sword -> Verb (Tab) -> Add a verb ->
(hopefully you can set it up in the GUI~Editor)
in code, it looks like this:
<object name="wooden_sword">
<inherited name="editor_object" />
<verb name="buy"><![CDATA[
if (player.cash >= wooden_sword.price) {
wooden_sword.parent = player
player.cash = player.cash - wooden_sword.price
} else {
msg ("You can't afford that item!")
}
]]></verb>
</object>
this isn't the best way to do this stuff, but it's the simpliest. If you want a better way, it'll get a bit more complicated, such as with using Object Types and etc.
----------
The Attribute Types:
your most basic type is the String, which is just a bunch of characters (letters, numbers, underscores, and etc):
Examples of Strings:
dead
wooden_sword
dungeon_level_5
alk329dndnljasdf3993893
a
3
when we apply an equal expression with a number to a String, we have our Integer (int) Attribute Type:
String: cash
Integer: cash=0
when we apply an equal expression with a decimal number to a String, we have our Double Attribute Type:
String: cash
Double: cash=0.0
when we apply an equal expression with a "true" string or "false" string to a String, we have our Boolean Attribute Type:
String: dead
Boolean: dead=false
while not the Boolean Attribute Type, there's many other forms of booleans (string=string) too:
(booleans are maybe better understood as "flags")
String: tv_power
"boolean": tv_power=off
String: answer
"boolean": answer=no
String: answer
"boolean": answer=1
String: race
"boolean": race=human
A Script Type Attribute is one (a Script) or more (a Script Block) expression lines:
if (orc.hp=0) {
player.cash = player.cash + orc.cash
player.experience = player.experience + orc.experience
foreach (item_x,orc.item_list) {
item_x.parent=player
}
orc.dead=true
}