Transferring script with arguments

H

HUMMAN

Guest
This is how i transfer my scripts;

an object:
array[x][y]=sc_example;

an other object:

script=array[x][y] // (using relation for instance and with function etc. written for simplification)

if(something_happens)
{
script_execute(script);
}

The code WORKS intended for non-argument scripts. But i want to do: // i know snytax is wrong but a good way to express my desire
array[x][y]=sc_example(argument1, argument2...); but as you now it doesnt work. I want to define and assign arguments in the first object, but i couldn't figure it out.
 

TsukaYuriko

☄️
Forum Staff
Moderator
You can pass around an array including the script as well as its arguments, then call it accordingly:
GML:
call = [ myscript, myargument ];

var func = call[0];
var arg = call[1];
func(arg);
If the amount of parameters is not known, you can wrap the arguments in their own array and pass in an array of arguments:
GML:
call = [ myscript, [ myargument, myargument ] ];

var func = call[0];
var args = call[1];
func(args);
 
H

HUMMAN

Guest
so it is not possible to define it locally? The reason i desire it the script reader is supposed to deal with scripts with unknown arguments.
Ok thought about it and i think your solution is good enough. Thanks!
 
Top