How do I multiply instance variables

Get help using Construct 2

Post » Sun Nov 22, 2015 3:13 pm

My game is a mining game. When I have Gold bars I want to sell them to a trade shop in return for money.
I am using instance variables so when I transfer my "Gold Bar instance variables" to "Amount of money instance variables" it will change "10 Gold bars Instance variables" to "10 Amount of money instance variables"
I need it to change from "10 gold bars" to say "100 amount of money" so how can I make the instance variables multiply with each other?
B
6
S
1
Posts: 48
Reputation: 505

Post » Sun Nov 22, 2015 3:51 pm

If you are trying to set the amount of money after the purchase:
Add action > system > Set value. On variable you set the amount of money and the value I dunno, set it to amount of gold * 10 or something. It depends on how you want the transaction to work.

If the player already have some money, use Add value instead. Add to the amount of money the amount of gold times something.
B
16
S
6
Posts: 259
Reputation: 2,349

Post » Sun Nov 22, 2015 3:52 pm

Would this work?

sprite set variable amountofmoney : 10*sprite.GoldBars
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Nov 22, 2015 3:58 pm

Create objects of gold bars, sprites, so each sprite representing each gold bar there will be an instance of gold variable name, this for each gold bar representing certain amount of money. Create a global variable name of money then multiply the values of the corresponding gold bars for 10 and assigns the variable money to this value.
B
28
S
9
G
3
Posts: 280
Reputation: 4,162

Post » Sun Nov 22, 2015 4:16 pm

I added the *10 to the end and it worked.
Event: "Mouse click on shop" Add Action: "Amount of money Instance Variables" Add to "Gold Bar Instance Variables*10"
B
6
S
1
Posts: 48
Reputation: 505


Return to How do I....?

Who is online

Users browsing this forum: alajajm, imhotep22 and 11 guests