Page 1 of 1

serious code problem

PostPosted: Tue Jan 22, 2008 9:47 pm
by DarkParadox
heres the code:
Code: Select all
if(keyAmount.textNumber == 1 || keyAmount.textNumber > 1 && animpos == 0)
{
ChangeAnimationDirection("Event Actor", FORWARD);
keyAmount.textNumber-=1;
}


and for some wierd reason the door only opens if keyAmount's text number = 1 exactly,
can someone either fix this code or give me another code for this.
i also tryed this code but it had to equal zero to open the door is this a glitch?

Code: Select all
if(keyAmount.textNumber > 0 && animpos == 0)
{
ChangeAnimationDirection("Event Actor", FORWARD);
keyAmount.textNumber-=1;
}

Re: serious code problem

PostPosted: Wed Jan 23, 2008 12:35 am
by Game A Gogo
this should work better:
Code: Select all
if(keyAmount.textNumber >= 1 && animpos == 0)
{
    ChangeAnimationDirection("Event Actor", FORWARD);
    keyAmount.textNumber-=1;
}


if it gives out an error, put "=>" instead of ">=" I forgot which one goes first...

Re: serious code problem

PostPosted: Wed Jan 23, 2008 12:50 am
by DarkParadox
now it's messing up with the subtraction, its removing all the keys instead of 1.

Re: serious code problem

PostPosted: Tue Jan 29, 2008 1:40 pm
by DocRabbit
What event is your code running under? Keydown or Draw? If keydown, make sure repeat is turned off or it would subtract down multiple times even though you think you hit key once.

Re: serious code problem

PostPosted: Tue Jan 29, 2008 4:51 pm
by Game A Gogo
This problem has been solved over with the chat room. I forgot what it was, but he figured it out himself :3