[** Programming error: objectloop broken because the object remote
control unit was moved while the loop passed through it **]
with this code:
objectloop(i in player)
{move i to bookcase;}
?????
--
"So... you've compiled your own Kernel... Your skills are now complete..."
-----------------
It's a bird
It's a plane
No it's... Gadget?
Village Magazine: http://www.villagemagazine.nl
To send E-mail: remove SPAMBLOCK from adress.
> Why do I get this message when the game is running:
>
> [** Programming error: objectloop broken because the object remote
> control unit was moved while the loop passed through it **]
>
> with this code:
>
> objectloop(i in player)
> {move i to bookcase;}
>
> ?????
I'm pretty sure the DM covers this, but just in case it doesn't:
Objectloops of the form objectloop(x in y) use the object tree to loop
over objects. In other words, it's equivalent to doing:
x = child(y);
while (x)
{
! do stuff
x = sibling(x);
}
As you can see, this will break if the code inside the objectloop moves
the object in question. Something along the way realises this and spouts
out an error.
The most efficient way to do what you want to do is like this:
while (child(player))
{
move child(player) to bookcase;
}
A more general but less fast approach is to use
objectloop (x)
{
if (x in player) move x to bookcase;
}
IIRC, this sort of objectloop doesn't use the object tree and so won't
break. Someone please shout at me in a nice way if I'm wrong.
HTH, jw
>Gadget <gad...@SPAMBLOCKhaha.demon.nl> wrote:
>
>> Why do I get this message when the game is running:
>>
>> [** Programming error: objectloop broken because the object remote
>> control unit was moved while the loop passed through it **]
>>
>> with this code:
>>
>> objectloop(i in player)
>> {move i to bookcase;}
>>
>> ?????
>
>I'm pretty sure the DM covers this, but just in case it doesn't:
It doesn't. It mentions the Objectloop in the beginning of the manual
but it doesn't explain these kind of things.
>Objectloops of the form objectloop(x in y) use the object tree to loop
>over objects. In other words, it's equivalent to doing:
>
>x = child(y);
>while (x)
>{
> ! do stuff
> x = sibling(x);
>}
>
>As you can see, this will break if the code inside the objectloop moves
>the object in question. Something along the way realises this and spouts
>out an error.
>
>The most efficient way to do what you want to do is like this:
>
>while (child(player))
>{
> move child(player) to bookcase;
>}
>
>A more general but less fast approach is to use
>
>objectloop (x)
>{
> if (x in player) move x to bookcase;
>}
>
>IIRC, this sort of objectloop doesn't use the object tree and so won't
>break. Someone please shout at me in a nice way if I'm wrong.
>
>
>HTH, jw
>
Thanks. The while-loop does the trick just as I wanted. And thanks for
explaining why my version did not work.
Yeah, there was a warning in an older version but it seems to have vanished.
Joe
The info is presumably in DM4 (grr), though it can be found at gmd
currently at:
ftp://ftp.gmd.de/if-archive/programming/inform6/manuals/dm_supplement.txt
-Lucian
And thus another IF year is born. Happy new year, everyone!
-=- Mark -=-
eh????????????
Try this:
objectloop(i)
{if (i in player) move i to bookcase;
}
I think there's some sort of optimization when you use a condition in
objectloop.
--
Andrew MacKinnon
andrew_mac...@yahoo.com
http://www.geocities.com/andrew_mackinnon_2000/
It is an odd comment - this question has been asked twice in the few months
I've been listening, it must give very short IF years (So! the six-monthly
comps _are_ annual, the best of both sides, right?).
John
>> >> [** Programming error: objectloop broken because the object remote
LOL!
Erm, but if I follow your logic, the current comp is only once every
*two* if years. So we should now have *four* to get two every IF year.