# How do I write this expression correctly?

Get help using Construct 2

### » Sat Mar 08, 2014 6:55 am

Does Construct 2 allow for the ability to write expressions in this fashion?

Variable PCurrentHP

Value Slot = 1 ? PlayerPokemon.At(S1, 4) :
Slot = 2 ? PlayerPokemon.At(S2, 4) :
Slot = 3 ? PlayerPokemon.At(S3, 4) :
Slot = 4 ? PlayerPokemon.At(S4, 4) :
Slot = 5 ? PlayerPokemon.At(S6, 4) :
Slot = 6 ? PlayerPokemon.At(S6, 4) : 0

It's supposed to check which Pokemon the player has active and load a saved current HP from the Pokemon's corresponding array.
I have similar functions for each stat, however some are more complicated and involve algorithms to determine stats (MaxHP for example involves a long formula utilizing level and BaseHP among other variables).

I only ask this because I'm not being given any particular errors, but I don't think that it is functioning correctly and I can't tell if that's coming from the way I've set up the expression, or from some other faulty programming.
B
3
Posts: 4
Reputation: 187

### » Sat Mar 08, 2014 9:45 am

You'll have to check for the active pokemon through events. The way you have it set up now is that PCurrentHP is be given a value of "Slot = 1 ? PlayerPokemon.At(S1, 4) : Slot = 2 ? PlayerPokemon.At(S2, 4) : Slot = 3 ?, etc, etc."

Instead you have use events that compare Global Variable for which pokemon is active and THEN set the value of PCurrentHP to "PlayerPokemon.At(S?, 4)"

You could also try set value of PCurrentHP to "PlayerPokemon.At(s&(whatever the slot variable you're using is called), 4)" I've not tried doing it this way, but I don't see why it wouldn't work. The previous method should work 100% though.

Hope this helps
B
70
S
10
G
9
Posts: 300
Reputation: 8,962

### » Sat Mar 08, 2014 3:12 pm

Thank you! I will try this and see if it solves my problem.
EDIT: How exactly would I go about checking for the pokemon that's active and then carry it over to the next event, if that what you're saying? Could you possibly write out an example so that I could see how it's done?
Thanks alot!

I think I could probably make another vairbale called Pokemon active which borrows from S1, S2, S3 and so on that is used in the expression.
B
3
Posts: 4
Reputation: 187

### » Tue Mar 11, 2014 9:01 am

I would just use another variable like you mentioned, variables are your friend
B
70
S
10
G
9
Posts: 300
Reputation: 8,962