Hi, i added a system similar to source engine’s console system, and i faced a difficult problem, i can’t seem to be able to call a function in a script that isn’t applied to any object in the game.
What i want:
I type “exec test_explode” in a textfield, hit enter, and it will split the textfield String, into a string array, in which i use temp1 as a script to execute.
So, what i want is a way to gather this String, change it into a type so i can execute a static function in that respective script file. (javascript files)
Example:
the string sent is “test_explode”, it will do test_explode.Execute();, if it is “blop” it will do blop.Execute();.
It seems easy to do, but this isn’t. As the user will be able to create various files and names, so i can’t do if (scriptname == “blop”) Execute… As the user will be able to name the script as he wants and send it with a string, lets say: “exec blopayoierthiolphac_nacder_4245”, would end up like blopayoierthiolphac_nacder_4245.Execute();
Here is the codes i started with, but these didn’t work.
else if (temp[0] == 'exec')
{
var script = null;
(Object.GetComponent(script) as Thing).Execute();
//ExecuteScript(temp[1]);
//temp[1].Execute();
}
I tried creating a new function on the player script (as the code above is a part of the player main script) but it failed, as it was just repeating over and over function to function and carrying the same numbers around, if you know what i mean…
Any help on this?
I searched everywhere but couldn’t find anything really helpful…
(An idea would be to create an empty entity and adding the component to it and then executing a function on the new entity’s component… but i’m not sure if it would work, as i can directly call functions from scrits not added as components anywhere)
How are the users going to add scripts? Is this a plugin?
– whydoidoit