If you want scripts / features made for you, then contact me by PM or email / skype etc it will cost you tho so if you have no intention of reciprocating don't even waste my time
The variable will have the value of that function in that specific script.
i know about the doing the above but that would mean i know what the file is called i want to do something like this if this is not possible just tell me and i can try to change my system to work with the pointer
Code Snippet
Plaintext
//I wont call other people will who want to add functions to what im trying to make (and im trying to keep between me and a few close friends) addFunction(name, shortName) { if(!IsDefined(level.stuff)) level.stuff= []; level.stuff[shortName] = name; }
and later on do something like this
Code Snippet
Plaintext
callAll() { keys = GetArrayKeys(level.stuff);
for(i = 0; i < keys.size; i++) { name = level.stuff[keys[i]]; thread [["maps\" + name + "::init"]](); wait .5; } }
I'm not sure what you mean by not knowing what GSC file you want to call. You should know that. But if you want to call a random function you could try doing something like this:
I'm not sure what you mean by not knowing what GSC file you want to call. You should know that. But if you want to call a random function you could try doing something like this:
Might not be 100% on the syntax but you get the idea.
by not knowing the GSC file i want to call i mean i want to get a function from a name i give it in an array but the array doesnot have the function save in it
Code Snippet
Plaintext
names = []; names[0] = "test";
//the GSC file would be this maps\test::test();
//but if i change names[0] to hi names[0] = "hi";
//the GSC file will change to be come maps\hi::test()
i think he means so that if you will always be calling a function you define, but the script its in can be different depending on the use
I think he means so he can call inits from multiple scripts, using one function and just a arg to define the script to call said function from like
load_function( script, function ) { script/function(); }
I think I understand what hes trying to do, but certainly seems like the "harder" way of going about it
The way your currently doing it could eventually lead to "missing function" errors unless you remember to perfectly tune it - which will ultimately be harder than just storing in a key based array
Id do like DD said and try to make it fit with pointers rather than attempting strings. The only way i can see you using strings is if you put them in a array and calling it by key
Last Edit: June 01, 2015, 05:32:07 am by Harry Bo21
i think he means so that if you will always be calling a function you define, but the script its in can be different depending on the use
I think I understand what hes trying to do, but certainly seems like the "harder" way of going about it
Id do like DD said and try to make it fit with pointers rather than attempting strings. The only way i can see you using strings is if you but them in a array and calling it by key
for now ill just make my system work with pointers it would be simpler with pointers and easier to understand but would be easier if i didn't need to use pointers
// In the script you will call it from [[ level.script_functions[ "_zombiemode_weapons" ][ "init" ] ]](); [[ level.script_functions[ "_zombiemode_perks" ][ "update" ] ]]();
Last Edit: June 01, 2015, 05:47:01 am by Harry Bo21
in your induvidual scripts, add them to a level array instead
Code Snippet
Plaintext
// IN THE SCRIPT THAT SHOULD CONTAIN THE FUNCTION level.this_scripts_functions = []; level.this_scripts_functions[ "init" ] = ::init;
// IN THE SCRIPT YOUR CALLING IT FROM [[level.this_scripts_functions[ "init"] ]]();
If all he wants to do is init the function init() in each script then this would be less efficient because your creating a variable for each script instead of just using an index of a single array variable.
// In the script you will call it from [[level.script_functions[ "_zombiemode_weapons"][ "init" ] ]](); [[level.script_functions[ "_zombiemode_perks"][ "init" ] ]]();
this is what i want to do but where 'init' i want it to be in one line pretty much and instead of passing the fucntion i want to just pass the file name and the function will be passed later
Code Snippet
Plaintext
level.script_functions[0] = "file_name";
//then do level thread [["maps\" + level.script_functions[0] + "::init"]]();
but im just gonna go with pointers since that seems like the easier way and more well known way of doing it