SCRAPPED: Condition if / else if with loops and connected loop problem

Started by Slasher, Fri 06/09/2013 19:09:25

Previous topic - Next topic

Slasher

Hi,

I would like to know if you add loop 3 to 2 (continuous movement L R R L)you can still have 'if' loop 2 or 'else if' loop 3 because at the moment only loop 2 seems to apply to the condition as it should be (Yes I know its not loop 1 and 2 (L R)).


As in Rep Exe:
Code: ags

}
 else if (PPColliding.OWithO(opurpbanana, otop2))
 
 if(omonkey.View==84 && omonkey.Loop==2)
 {  
  cSpaceman.ActiveInventory=null; 
  omonkey.Move(opurpbanana.X-0, opurpbanana.Y+30, 20, eBlock, eAnywhere);
  opurpbanana.Graphic=2472;
  omonkey.Move(omonkey.X+200,  omonkey.Y-0, 4, eBlock, eAnywhere); // THIS WORKS through to end ok
  omonkey.Visible=false;
  opurpbanana.Move(cSpaceman.x+0, cSpaceman.y-0, 4, eBlock, eAnywhere);
  mouse.Mode =eModeInteract;
  cSpaceman.Say("The monkey dropped the tyre for the purple banana. Good thing I helped that alien. I don't need bananas anymore.");
  cSpaceman.LoseInventory(ipurpban);
  }
  else if(omonkey.View==84 && omonkey.Loop==3)
  {
  cSpaceman.ActiveInventory=null;
  omonkey.Move(opurpbanana.X-0, opurpbanana.Y+30, 20, eBlock, eAnywhere);
  opurpbanana.Graphic=2472;
  omonkey.Move(omonkey.X-200,  omonkey.Y-0, 4, eBlock, eAnywhere); // THIS MOVES AS IF Loop 2
  omonkey.Visible=false;
  opurpbanana.Move(cSpaceman.x+0, cSpaceman.y-0, 4, eBlock, eAnywhere);
  mouse.Mode =eModeInteract;
  cSpaceman.Say("The monkey dropped the tyre for the purple banana. Good thing I helped that alien. I don't need bananas anymore.");
  cSpaceman.LoseInventory(ipurpban);
   
 } 


If you spot any errors and/or can assist me with this I would be grateful.

Meanwhile I will look into this further.

Cheers






Slasher


Andail

Quote
I would like to know if you add loop 3 to 2 (continuous movement L R R L)you can still have 'if' loop 2 or 'else if' loop 3 because at the moment only loop 2 seems to apply to the condition as it should be (Yes I know its not loop 1 and 2 (L R)).
I don't think you've explained very well what is going on, which is why people hesitate to answer.

PPColliding.OWithO(opurpbanana, otop2)  <-- what is this?

Also note that there's a "{" missing on line 3 (or end of 2, however you want it), and all the code is weirdly indented.

All these loops, are they for showing/setting which direction the object will move? Is there a reason you haven't just made the monkey a character, that can walk around?

But ok, the object "omonkey" has a loop 2 which has loop 3 attached to it, to make it extra long, correct? And even though the code is triggered as if he was in loop 3, he still begins moving in loop 2? Is that it? Just trying to understand the problem.


Slasher

Hi Andail,

what I was attempting to do was quite complex and probably a 'bridge too far'... I'v since scrapped that idea and have re-thought the situation and have done a more durable animation and script that is working perfect.

Yes, I know that the script was not perfectly laid out etc but I was in a bit of a turmoil at that time.


Cheers




Khris

Just for reference:
You can check multiple conditions like this:
Code: ags
  if (omonkey.View == 84 && (omonkey.Loop == 2 || omonkey.Loop == 3)) {
    ...
  }

Not sure exactly how AGS handles it internally if you check "Run next loop after this"; I assume a copy is attached to end, database-wise. So AGS should have Loop == 2, even during frames that are actually in the view editor's loop 3. I'm too lazy to test this though.

Slasher

Thanks Khris,

That's nice to know.

Unfortunately the way the loops were made made it quite impossible to implement. I will keep what I have learnt about this for any future implementations of a similar nature.

cheers


Ryan Timothy B

Quote from: slasher on Mon 09/09/2013 10:55:12
Unfortunately the way the loops were made made it quite impossible to implement. I will keep what I have learnt about this for any future implementations of a similar nature.
How so? Your response confuses me.

It would simply be like this (your code for both conditions is identical):
Code: ags
if (PPColliding.OWithO(opurpbanana, otop2)) {
  if (omonkey.View == 84 && (omonkey.Loop == 2 || omonkey.Loop == 3)) {  
    cSpaceman.ActiveInventory = null; 
    omonkey.Move(opurpbanana.X - 0, opurpbanana.Y + 30, 20, eBlock, eAnywhere);
    opurpbanana.Graphic = 2472;
    omonkey.Move(omonkey.X + 200,  omonkey.Y - 0, 4, eBlock, eAnywhere); // THIS WORKS through to end ok
    omonkey.Visible = false;
    opurpbanana.Move(cSpaceman.x + 0, cSpaceman.y - 0, 4, eBlock, eAnywhere);
    mouse.Mode = eModeInteract;
    cSpaceman.Say("The monkey dropped the tyre for the purple banana. Good thing I helped that alien. I don't need bananas anymore.");
    cSpaceman.LoseInventory(ipurpban);
  }
}

Fortun

Quote from: Ryan Timothy on Mon 09/09/2013 22:53:01
It would simply be like this (your code for both conditions is identical):

I can see one difference ;)

Code: ags
if (PPColliding.OWithO(opurpbanana, otop2)) {
  if (omonkey.View == 84 && (omonkey.Loop == 2 || omonkey.Loop == 3)) {  
    cSpaceman.ActiveInventory = null; 
    omonkey.Move(opurpbanana.X - 0, opurpbanana.Y + 30, 20, eBlock, eAnywhere);
    opurpbanana.Graphic = 2472;
    if (omonkey.Loop==2)    omonkey.Move(omonkey.X + 200,  omonkey.Y - 0, 4, eBlock, eAnywhere);
    else     omonkey.Move(omonkey.X - 200,  omonkey.Y - 0, 4, eBlock, eAnywhere);
    omonkey.Visible = false;
    opurpbanana.Move(cSpaceman.x + 0, cSpaceman.y - 0, 4, eBlock, eAnywhere);
    mouse.Mode = eModeInteract;
    cSpaceman.Say("The monkey dropped the tyre for the purple banana. Good thing I helped that alien. I don't need bananas anymore.");
    cSpaceman.LoseInventory(ipurpban);
  }
}

sorry for my bad english (-_-)

SMF spam blocked by CleanTalk