• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[Solved] Prevent variable "feeding in" in Step Event.

Hi,

A small issue I'm having. I have a code to check an energy level. If the energy level is at or above a certain amount, do stuff, if not, do something else. Simple enough. However, it seems that the check for greater than or equal to also feeds into the less than check. I'd like both to occur individually within the Step Event. Here is what I have in the Step Ev:

NOTE: en_curr is just the current energy level and en_req is the required energy level. The variables 'spc_type' refer to the input to perform the action. Also, 'scr_ingame_en_lack' just refers to a script which tells the object what to do if there is not enough energy after performing the input.

Code:
if (spc_type='dd_lt' and en_curr>=en_req)
or (spc_type='dd_hv' and en_curr>=en_req)
            {
            en_curr-=en_cons
            //do stuff if enough energy 
            }
if (spc_type='dd_lt' and en_curr<en_req)
or (spc_type='dd_hv' and en_curr<en_req)
            {scr_ingame_en_lack();}
If the energy is much higher than the required level (ex. if its full), it works fine. But, If the energy level is only slightly above the required level, and the input is done to perform the action, it "falls" below the required level and thus performs both actions. How do I ensure this does not happen and that both actions are performed separately?

Thanks!
 
Last edited:
D

David Berkompas

Guest
I'll be sending out the invoice for consultation work tomorrow.


Dave
 
Top