less than, equal to issues (Solved)

Started by DrewCCU, Fri 07/05/2010 00:16:51

Previous topic - Next topic

DrewCCU

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:
Code: ags

int Thing=120;


and in my repexec script i have this:
Code: ags

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:
Code: ags

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


but that didn't work either. little helpplease.
"So much of what we do is ephemeral and quickly forgotten, even by ourselves, so it's gratifying to have something you have done linger in people's memories."
-John Williams

Ryan Timothy B

Code: ags

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.

DrewCCU

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.
"So much of what we do is ephemeral and quickly forgotten, even by ourselves, so it's gratifying to have something you have done linger in people's memories."
-John Williams

SMF spam blocked by CleanTalk