quick question

Game Editor comments and discussion.

quick question

Postby NightOfHorror » Thu Dec 29, 2011 10:47 pm

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?
viewtopic.php?f=2&t=12136
"I have not failed. I just found 10,000 ways that wont work." quoted by Thomas Edison.
Over the year, I decided my motto for me is I am knowledgeable, but not practical.
User avatar
NightOfHorror
 
Posts: 1823
Joined: Fri Aug 27, 2010 2:50 am
Location: Cedar Hill, MO, of the USA
Score: 51 Give a positive score

Re: quick question

Postby skydereign » Thu Dec 29, 2011 10:54 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: quick question

Postby NightOfHorror » Thu Dec 29, 2011 11:28 pm

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);
}
viewtopic.php?f=2&t=12136
"I have not failed. I just found 10,000 ways that wont work." quoted by Thomas Edison.
Over the year, I decided my motto for me is I am knowledgeable, but not practical.
User avatar
NightOfHorror
 
Posts: 1823
Joined: Fri Aug 27, 2010 2:50 am
Location: Cedar Hill, MO, of the USA
Score: 51 Give a positive score

Re: quick question

Postby skydereign » Thu Dec 29, 2011 11:35 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest