condition if all objects off (visible: false)

Started by barefoot, Mon 15/02/2010 20:59:19

Previous topic - Next topic

barefoot

Hi

I am looking for a condition that when certain Objects are NOT visible a condition can be run such as change room... (Opposite condition of below code)

'After killing an Object it is switched off (visible true/false)..   I have 3 objects.'


Code: ags

if ((oMobster1Dead.Visible) && (oMobster2Dead.Visible) && (oMobster3Dead.Visible)) {
  Display("You have killed the 3 Mobsters and it's now safe to pass")
  player.ChangeRoom(23, 55, 371);
}


I have looked but not found the answer yet.

All help appreciated
barefoot
I May Not Be Perfect but I Have A Big Heart ..

Khris

Code: ags
  if (!oMobster1Dead.Visible && !oMobster2Dead.Visible && !oMobster3Dead.Visible) {

barefoot

Thanks so much Khris

You helped me big time

cheers

barefoot
I May Not Be Perfect but I Have A Big Heart ..

suicidal pencil

There's another method that will let you use the same code over and over again for each room. Especially when you have too many objects in a room, and doing the if(!object[0].Visible && !object[1] && .......

Code: ags

function GetVisibility()
{
  int counter = 0;
  int false_count = 0;
  while(counter <= Room.ObjectCount)
  {
     if(!object[counter].Visible) false_count++;
  }
  if(false_count == Room.ObjectCount) return true;
  else return false;
}

Khris

You have to stop the iteration at Room.ObjectCount - 1; object numbering starts at 0.

suicidal pencil

Quote from: Khris on Tue 16/02/2010 18:09:40
You have to stop the iteration at Room.ObjectCount - 1; object numbering starts at 0.

yes, I know it starts at 0, and if you have all 40 objects in a room, that loop should stop when counter hits 39

Khris

You have
Code: ags
 while(counter <= Room.ObjectCount) 


So at the last iteration, counter == Room.ObjectCount.

Plus - just saw that - you aren't incrementing counter.

SMF spam blocked by CleanTalk