How do I write this expression correctly?

0 favourites
  • 4 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • 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.

  • I would just use another variable like you mentioned, variables are your friend

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)