This site works best with JavaScript enabled. Please enable JavaScript to get the best experience from this site.
Confusing title, I know. lol
If I have a string, "functionX", would it be possible to call the function, functionX, somehow with this string? Instead of just going
string k = functionX; if (k == "functionX") { functionX(); }
Is there a way to convert the string straight into calling the function?
You could use a trigger, like this:
bool functionX(bool a, bool b) { return false; } string k = "functionX"; trigger t = TriggerCreate(k); TriggerExecute(t,false,false);
However, trigger function always have to take 2 bool parameters and return bool, so you are kind of limited here or need to use globals to pass other parameters.
If it is just about storing functions in a variable, you can use funcrefs instead.
Confusing title, I know. lol
If I have a string, "functionX", would it be possible to call the function, functionX, somehow with this string?
Instead of just going
string k = functionX;
if (k == "functionX")
{
functionX();
}
Is there a way to convert the string straight into calling the function?
You could use a trigger, like this:
However, trigger function always have to take 2 bool parameters and return bool, so you are kind of limited here or need to use globals to pass other parameters.
If it is just about storing functions in a variable, you can use funcrefs instead.