Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Jim_Smitts on Thu 22/04/2010 08:04:18

Title: Two-Part Room Event Functions? {Solved}
Post by: Jim_Smitts on Thu 22/04/2010 08:04:18
I have two scripts that I need to have repeatedly execute.  I can run one function or the other under room_RepExec(). :-\

How do I get two functions to run on the room_RepExec() event, or any other room event? ???  I cannot imbed a function or import a function within a function.  Is there a way to add more events to the room event list?  I basically need to somehow split the event into RepExec1 and RepExec2 functions.
Title: Re: Two-Part Room Event Functions?
Post by: Gilbert on Thu 22/04/2010 09:15:04
I'm not quite sure what you're after, but if you're say, talking about calling two different functions according to different conditions, you can always do something like:

function fun1(...){
  ...
}

function fun2(...){
  ...
}

function room_RepExec(){
  if (...) fun1(...);
  else fun2(...);
}

Title: Re: Two-Part Room Event Functions?
Post by: Jim_Smitts on Thu 22/04/2010 09:56:13
No, not according to two different conditions.  I need two identical functions to loop simultaneously.  I need two npcs to walk a loop.

I have two functions, one for each character, and I can run either under function room_RepExec().  So I can one npc walk a loop or the other.  Now having one character walk a loop is one function that I need to have run under function room_RepExec(), but I need to have two functions run at the same time and repeatedly execute.

Either function works as function room_RepExec(), so if, say, I had function fun1() and function fun2() I'd have nothing to put in the (...).
Title: Re: Two-Part Room Event Functions?
Post by: GarageGothic on Thu 22/04/2010 10:14:19
Still, it's the same thing:

function room_RepExec() {
 if (!cGuyA.Moving) { //character GuyA is standing still
   cGuyA.Walk (100,100, eNoBlock); //start him walking
   cGuyA.AddWayPoint(230, 150); //add some more waypoints to his path
   cGuyA.AddWayPoint(20, 120);
  }
 if (!cGuyB.Moving) { //character GuyB is standing still
   cGuyB.Walk (40,139, eNoBlock); //start him walking
   cGuyB.AddWayPoint(59, 29); //add some more waypoints to his path
   cGuyB.AddWayPoint(299, 100);
   }
 }


Coordinates were chosen totally at random, so don't mind the numbers.
Title: Re: Two-Part Room Event Functions?
Post by: Khris on Thu 22/04/2010 12:08:53
Yeah... I really don't see the problem here.

To use Gilbet's example:

function fun1(){
  ...
}

function fun2(){
  ...
}

function room_RepExec(){
  fun1();
  fun2();
}
Title: Re: Two-Part Room Event Functions? {Solved}
Post by: Jim_Smitts on Thu 22/04/2010 15:10:18
Well I got them to work. 8)  Thanks everyone!  ;D