Solitary Confinement
Member
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.
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!
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();}
Thanks!
Last edited: