a function that calls a function by name

Started by Superman95, Sat 17/09/2005 03:42:19

Previous topic - Next topic

Superman95

Is there a way to do something like this?

function CallMe()
{
  // something useful;
}

// later in script say,
execute("CallMe");

and execute the method by name instead of calling it.  I'm sure you're wondering why.  I was thinking about a module, and I wanted to be able to write AI code someplace else, but let the module call it without really knowing about.  So, the client of the module could say,

function MyAI()
{
   // smart ai coding
}
// call a method to register the ai function.
RegisterMyAIFunction("MyAI");

Then, the module could call it when neccessary.

So, basically, does anyone know of a function that lets you call another function by name?

Pumaman

That is not currently supported by AGS, because it would require some sort of run-time linking that it not supported by the script engine at the current time.

I can see the uses of this in allowing a module or the global script to call room scripts, so I'm not ruling it out, but it certainly won't happen soon, I'm afraid.

SMF spam blocked by CleanTalk