Bug in assigning loop & cel to objects

Randy Alright, I'm having trouble with another bug I've been coming across a few times. I have a view that has 3 loops: the 1st & 2nd loops have multiple cels while the last loop has only 1 cel. I want to animate the first loop through once, then the second loop through once, then change to the last loop and move the object from the right of the screen to the left of the screen.

Sound simple, right? I initialize the object like any other and use the "end.of.loop" command to set a flag after the first loop is done. When that flag is set, I reset it and use the "set.cel" & "set.loop" commands to change to the 1st cel in the 2nd loop and the "end.of.loop" command to set a second flag after the second loop is done. Then when the second flag is set, I reset it and use the "set.cel" & "set.loop" commands again to change to the last loop and the "move.obj.v" command to move the object to the left of the screen.

However, everytime I run this, the object always reverts to the 1st cel of the 2nd loop when the "move.obj.v" command is issued. I've tried using just the "move.obj" command and the same bug occurs. I remove the "move..." command altogether and the object displays the 3rd loop's cel properly (but doesn't move, obviously). I've had this happen on other occasions too and simply created a new view and object for the "move" command. I can't afford too many erroneous views and objects in this scene so I would like to use the same view if I could.

Any thoughts as to what could be causing this and how to circumvent it? Thanks.
sonneveld is it possible to post that portion of the code? it's alright to rename any #defines so the game isn't given away though.

- Nick
Randy Here's a sample of the part of the code that's been giving me trouble (I removed the define names to keep my project a surprise):

if (v150 > 1){
v150 = 1;

if (f91){

if (f92){
v50 = 2;

if (f93){

If I use "move.obj" instead of "move.obj.v" and use constants I still get the same bug, which is that object9 displays as Loop1.Cel0 instead of Loop2.Cel0. If I comment out the "move.obj.v" command in the code above, object9 appears as it is supposed to. However, once I get it to move again it reverts back to Loop1.Cel0.

I've even tried reassigning object4, instead of erasing it, to the same view object9 uses and Loop2.Cel0 of it. In this attempt, I then erased object9 when f92 is set and used the "move.obj.v" command on object4. This attempt failed too as object4 then reverted to Loop1.Cel0 whenever the object is moved.

I've experienced this same problem elsewhere, but coded around it by separating the 3rd loop out of the view and creating a new view using just that cel. I don't want to have to keep using this messy solution.
Kon-Tiki The normal thing is to place the set.loop before the set.cel. Don't know if this has anything to do with it, but I've got a feeling that this can help. Doesn't hurt to try anyway ;)

sonneveld I'm pretty sure that the order or setloop and cel doesn't matter but i could be wrong.

One thing to check would be to make sure that you're setting the right loop. There's a bug in AGI where this is possible:

1) create a view with 3 loops: loop 0, loop1, loop2
2) create an animated object in your game
3) set your loop to 0 - 2 .. this is ok
4) set your loop to 4,5,6,7.... this give an error
5) set your loop to 3. doesn't check bounds properly and reads random data.

NAGI checks for this.. but the dos interpreter probably doesn't.

- Nick
Andrew_Baker It would also be possible to break that one view up into multiple views to avoid such a conflict. Then, instead of set.loop, you would just use set.view. Granted, this requires more memory overhead, but you can call new.room after the animated sequence in order to free up this memory once you're done.