if hitpoints < 100 {
hitpoints += 25;
if hitpoints > 100 {
hitpoints = 100
}I know it's a very simple question, but any help would be appreciated.
And obviously, hitpoints is my variable.
Thanks a ton!
Posted 11 March 2012 - 07:54 PM
if hitpoints < 100 {
hitpoints += 25;
if hitpoints > 100 {
hitpoints = 100
}Posted 11 March 2012 - 07:58 PM
if global.hitpoints < 100 {
global.hitpoints+=25
}
else {
exit
}
But like I said, I am not sure..
Posted 11 March 2012 - 08:06 PM
Well I have never worked with health before, so is "hitpoints" the built in point system or a global var you made?
hitpoints SHOULD be appearing orange... Try this..if global.hitpoints < 100 { global.hitpoints+=25 } else { exit }But like I said, I am not sure..
Posted 11 March 2012 - 08:26 PM
Posted 11 March 2012 - 08:46 PM
if hitpoints<100 {
hitpoints+=25
instance_destroy()
}
else
if hitpoints=100 {
exit
}
Posted 11 March 2012 - 09:11 PM
//Player collision event with potion
if (hitpoints < 100) {
//Cap the health
hitpoints = min(hitpoints+25, 100);
//Destroy the potion
with (other) {
instance_destroy();
}
}
It is definitely a variable that the original poster created. The built-in ones are score, health and lives. You can easily look this up in the manual and it won't be there, that should have told you that it is user-made.Well I have never worked with health before, so is "hitpoints" the built in point system or a global var you made?
If it is a custom-made variable, it should definitely not highlight orange by default.hitpoints SHOULD be appearing orange...
Again, if you're not sure, don't try to help.if global.hitpoints < 100 { global.hitpoints+=25 } else { exit }But like I said, I am not sure..
if hitpoints<100 {
hitpoints+=25
instance_destroy()
}
else
if hitpoints=100 {
exit
}
This still does not correctly solve the hitpoint cap problem. What if hitpoints is 85? You would increase it by 25 to 110 and stop there. You clearly haven't traced this piece of code very well.Posted 11 March 2012 - 10:57 PM
if hitpoints < 100
{
hitpoints = min(hitpoints + 25,100)
with (other) {instance_destroy()}
}
Edited by PetzI, 11 March 2012 - 11:01 PM.
0 members, 0 guests, 0 anonymous users