Home   Help Search Login Register  

Author Topic: simple loop not working  (Read 508 times)

0 Members and 1 Guest are viewing this topic.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
simple loop not working
« on: 17 Jul 2005, 17:32:15 »
here's the loop:

Code: [Select]
_i = 0
all_objects = []
_o = (object 0)

#loop
?(isnull _o): exit
all_objects = all_objects + [_o]
_i = _i + 1
_o = call format ["(object %1)",_i]
~.0001
goto "loop"

what its supposed to do is create an array of all the map objects

but a hint format shows that the array is empty.
 ??? ??? ??? ??? ??? ???

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:simple loop not working
« Reply #1 on: 17 Jul 2005, 17:55:59 »
my only thought is that there may be no object 0. if that's the case, the script exits and the array remains empty.

is there an 'object 0'?

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:simple loop not working
« Reply #2 on: 17 Jul 2005, 23:35:37 »
yes, i tested that on nogova
came up with some kind of house or something, anyway, i didn't get any kind error so there is definitely an object 0



another thing i just thought of: what if all objects are considered null by the game engine?
its a long shot but something is making it exit
« Last Edit: 17 Jul 2005, 23:38:04 by Triggerhappy »

qqqqqq

  • Guest
Re:simple loop not working
« Reply #3 on: 17 Jul 2005, 23:56:26 »
Add

hint format ["%1", all_objects
~3

into the loop to give you a better idea of what's happening.

If the array is coming up empty then the problem is right at the start since object 0 (which does exist IIRC) is not being added to the array.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:simple loop not working
« Reply #4 on: 18 Jul 2005, 02:14:08 »
i do have a hint format (in a radio trigger) that i used to find out what was in the array.  I ran the script (called it) form the init.sqs and it shouldn't run for more than a few seconds

the hint i get is:
[]

so i don't know whats happening

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:simple loop not working
« Reply #5 on: 18 Jul 2005, 04:55:30 »
Quote
another thing i just thought of: what if all objects are considered null by the game engine?
its a long shot but something is making it exit

odd but i think that was the problem, or something similar

by checking whether it was == to itself instead of whether it was null, the loop works fine.

quite odd indeed