Page 1 of 1

quick question

PostPosted: Thu Dec 29, 2011 10:47 pm
by NightOfHorror
okay, so I have it where in a game a value of a command is 2 which is how much you can use it. When you click this command it goes to 1, and then 0. After 0 it goes to negatives which I dont want. I put the code under the command in Create Actor
Code: Select all
if(command<=0);
{
EventDisable("command", EVENTALL);
}


All that does is disable the event even when the value of the command is higher than 0.

What is wrong with that code?

Re: quick question

PostPosted: Thu Dec 29, 2011 10:54 pm
by skydereign
Umm... you have a variable and and an actor named command? If you want to reduce a number until it is zero, via a mouse button down event, you can do something like this.
actor -> Mouse Button Down -> Script Editor
Code: Select all
variable-=variable>0;

Now the reason your code doesn't work is that it is in the create actor event. That will only trigger once at the actor's create. So, perhaps that actor is not the command actor, in which case you might be creating the actor before you reduce the variable. In that case switch them.

Re: quick question

PostPosted: Thu Dec 29, 2011 11:28 pm
by NightOfHorror
there is two things, these commands are those attack commands. I have the canvas actor punch which when you press it the variable M_punch_number_var-=1; so that would make the M_punch_number text go down one number. So pressing punch would make M_punch_number become1 if it was 2 and 0 if it was 1. So I accidently told you guys the code I did wrong. this is the exact code I used, and I would put it under where if not CreateActor.

Code: Select all
if(M_punch_number_var<=0);
{
EventDisable("punch", EVENTALL);
}

Re: quick question

PostPosted: Thu Dec 29, 2011 11:35 pm
by skydereign
Well, first off, I wouldn't use that code at all, unless there are actual events you want to disable. But if I were to, I would put it at the code that I decrement M_punch_number_var. Currently though it sounds like you want to decrease it as long as the variable is greater than zero (in which case you can decrease it like I suggested in my previous post), instead of just having to disable it.

What actor is being created? Does the mouse button down create an actor? Otherwise the event wouldn't trigger at every mouse event, and therefore would never actually call your code to disable the punch actor.