*Solved* How do I use local variables?

Get help using Construct 2

Post » Tue Dec 30, 2014 2:47 am

Hello, I am making a RPG style game, I have many classes and each class has attributes, I do not want to share these base attributes so I stuck them in a Group name "Warrior", "Mage", "Rogue", etc...

Each one of these groups I have created local variables:
Experience
Health
Strength
etc....


so later in my MainEvent Sheet I will add an action to add to Warriors health so how would I do this?

in programing terms I would do something like warrior.health + 10

how do I do this in construct?
Last edited by mordiaky on Tue Dec 30, 2014 3:33 am, edited 1 time in total.
B
8
S
1
Posts: 74
Reputation: 725

Post » Tue Dec 30, 2014 2:56 am

I feel that you've structured your variables wrong - character stats should be global variables, your class selection should then inform the global variable.

if Mage > set Health to 5
if Warrior > set Health to 10

etc.

Your damage events then become much easier to manage

onCollision with arrow > subtract(Defense-arrow.damage) from Health

for example
B
64
S
25
G
10
Posts: 653
Reputation: 10,840

Post » Tue Dec 30, 2014 2:57 am

ok that was my other way of thinking and I was already working with this.

Thank you very much
B
8
S
1
Posts: 74
Reputation: 725

Post » Tue Dec 30, 2014 3:13 am

I used instanced variables for stats in my turn based rpg demo. I put enemies and characters inside the same group and created the instanced variables in the group. There's probably different ways of doing stats, other people would prefer arrays.

viewtopic.php?f=148&t=120805
B
75
S
29
G
17
Posts: 256
Reputation: 15,250

Post » Tue Dec 30, 2014 3:32 am

Thank you guys for the fast reply. I will look into both options and see what option will be best for what I plan on doing. Thank you both again!
B
8
S
1
Posts: 74
Reputation: 725


Return to How do I....?

Who is online

Users browsing this forum: Magistross and 8 guests