Two-Part Room Event Functions? {Solved}

Started by Jim_Smitts, Thu 22/04/2010 08:04:18

Previous topic - Next topic

Jim_Smitts

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.

Gilbert

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:
Code: ags

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

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

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


Jim_Smitts

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 (...).

GarageGothic

Still, it's the same thing:

Code: ags
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.

Khris

Yeah... I really don't see the problem here.

To use Gilbet's example:

Code: ags
function fun1(){
  ...
}

function fun2(){
  ...
}

function room_RepExec(){
  fun1();
  fun2();
}

Jim_Smitts

#5
Well I got them to work. 8)  Thanks everyone!  ;D

SMF spam blocked by CleanTalk