Alternative to wait? (i want something to loop before going onto the next func)

Started by manny.p, Mon 20/06/2005 00:33:17

Previous topic - Next topic

manny.p

Hi this is in my rep_ex:
if (IsTimerExpired(2)==1) {
SetTimer(2, 12);
object[0].SetPosition(object[0].X-1,object[0].Y);



And this is in my after fadein:
SetTimer(2, 12);
Wait(400);
object[1].IgnoreWalkbehinds = 1;
object[1].Visible=true;


Now i want SetTimer 2 function to continue throughout the script even when it waits 400 cycles before the next function processes, but it stops as soon as i put that Wait in there so how can i change the code?

Ashen

Use rep_ex_always, maybe? (Will need to create it yourself.) I think that keeps processing when the game is Waiting.

Otherwise - what do you want to happen? There may be another way to achieve it.

Oh, and I'm fairly sure you can use object[0].X --; instead of object[0].SetPosition(object[0].X-1,object[0].Y);. Absolutely no difference, just quicker to type.
I know what you're thinking ... Don't think that.

manny.p

I'm a n00b at scripting, you'r gonna have to tell me how make that rep_ex_always

The reason i want this is because i want the clouds (object 0) to continue moving from it's position to the left while other objects appear and disappear (object.visible).

monkey0506

function repeatedly_execute_always() {
  /* you can't call blocking scripts within this function! */
  /* leave your other scripts the way they are, except remove the "SetTimer(2, 12);" line from after fade-in, and the "if (IsTimerExpired(2)==1)" block from rep_ex */
  if (IsTimerExpired(2)) { /* == 1 is optional in this case; it is passed as true if it is 1 */
    SetTimer(2, 12);
    object[0].X--; /* like Ashen said, a lot easier to write */
    }
  else SetTimer(2, 12);
  }

Actually, in this case the timer shouldn't ever expire...I'm not quite sure what you're trying to do (I'm kind of tired), but I hope this helps you figure it out.

Ashen

Actually, you need to leave the SetTimer (2,12) in 'after fade-in', and remove that else SetTimer(2,12); from rep_ex_always - the way it is now the timer will be constantly restarted, and never get a chance to expire (as monkey said).

And it goes in the room script, in case you were wondering -  just make sure it's outside all existing functions.

To clarify, your room script should look something like:
Code: ags

//room script file

 function repeatedly_execute_always() {
  /* you can't call blocking scripts within this function! */
  if (IsTimerExpired(2)) { // the '==1' is optional in this case
    SetTimer(2, 12);
    object[0].X--;
  }
}

#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
  // script for room: Player enter room (after fade-in)
  SetTimer(2, 12);
  Wait(400);
  object[1].IgnoreWalkbehinds = 1;
  object[1].Visible=true;
}
#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE

// Rest of room script ..........


('after fade-in' doesn't might not be room_a - they're labled in the order you create them. Just make sure the script cont ent is right.)
I know what you're thinking ... Don't think that.

Gilbert

You can only do stuff like declaring variables or static variable defining outside of functions. maybe you're talking about functions that run only once? :=

* Gilbot V7000a is tired too, so He didn't read all of this thread.

manny.p

hi thnx all, you solved my riddle, now i have an exact monkey island intro replica!

I got 2 more questions which i think are only possible in my imagination:

1. Change the background using a function?
Could i possibly make and animation backgrounds which loads the second frame when i ask it to using a funcion?

2. Instant room change, no transition effect?
FadeIn(60); doesn't work because character[EGO].ChangeRoom(1); is it's own function (you know what i mean), it there a way for a character to change the room without that transition effect?

strazer

1.) You can set the background to animate by adding background frames to the room, then use SetBackgroundFrame(0); in "Player enters screen (before fadein)" to pause the animation at the specified frame and finally use SetBackgroundFrame(-1); to start the animation.

If you need different delays for each frame, check out this thread.

2.) You can change the transition behaviour in the General settings pane, but if you only need it for one particular situation, you can do this:

Code: ags

  SetNextScreenTransition(eTransitionInstant);
  player.ChangeRoom(1);

SMF spam blocked by CleanTalk