Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: DrewCCU on Fri 07/05/2010 00:16:51

Title: less than, equal to issues (Solved)
Post by: DrewCCU on Fri 07/05/2010 00:16:51
Okay, this one is a little tricky to explain in simplest terms, but allow me to try:

I have defined an integer at the top of my room code:

int Thing=120;


and in my repexec script i have this:

if (Thing<=120) {
 Event1 happens;
}
if (Thing<=0) {
 Event2 happens;
}


Now I know the problem and I know why the problem is happening ... i just don't know how to fix it.

The deal is I want Event1 to happen if Thing (a variable that is constantly changing through the course of this room) <= 120 but as soon as Thing <= 0 I want Event2 to happen.  What's happening is that even though Thing becomes <= 0 Event2 isn't happening - it's staying on Event1.  I realize this is happening because 0 is <= 120 so it still fits the conditions set by  if (Thing<=120) {

But how do i set it up so that Event1 occurs only until Thing reaches <=0?

I've tried modifying the code and rearranging things but nothing seems to work.  I thought this would surely work:

if (Thing<=120) {
 Event1;
}
else if (Thing<=0 && !Thing>=0) {
 Event2;
}


but that didn't work either. little helpplease.
Title: Re: less than, equal to issues
Post by: Ryan Timothy B on Fri 07/05/2010 00:22:07

if (Thing<=0) {
  Event2 happens;
} else if (Thing<=120) {
  Event1 happens;
}


Since it's in your repex, this should do the trick with the else.
Title: Re: less than, equal to issues
Post by: DrewCCU on Fri 07/05/2010 00:25:45
WOw, that worked.  I thought i had tried that already ... i must have done it a little differently.

But i tried what you suggested and it worked ... thanks.