"The index does not exist."
- Your script is not in the Entity Scripts field in your logic_script
- You are calling a function or value which is not stated inside the code
- You have a syntax error inside your script. There may be an extra bracket, a random letter inserted somewhere that would break it etc.
Paste your code in a [code] tag and tell me what input you are giving it and I can give you an answer to why it isn't working.
function invertParent(){
// local ent = Entities.FindByTarget(null,"@counter_energyball_marker");
local ent = EntityGroup[0];
if(ent == null){
printl("ERROR: Countering Energy Ball:");
printl(" No Marker Found!");
return;
}
local theparent = ent.GetMoveParent();
if(theparent == null){
printl("ERROR: Countering Energy Ball:");
printl(" No Parent Found!");
return;
}
local angles = theparent.GetAngles();
angles *= -1;
angles = GetPlayer().GetAngles();
theparent.SetAngles(angles.x, angles.y, angles.z);
printl("COUNTER");
return;
}
printl("SCRIPTFILE RUN");
printl(randomVar);
To redirect a combine ball.
chickenmobile wrote:
...tell me what input you are giving it...
Would be great if you gave me whole error that comes up in console. Not just a generalised one. The code looks syntax error free to me.
EDIT: the player can also be referenced to as player.
e.g. local ang = player.GetAngles()
"Entity [logic_script entity] encountered an error in RunScriptCode: line 1: the index invertParent() does not exist."
Then an empty call stack and empty list of variables, since none had been defined. Input is RunScriptCode invertParent(); (which works fine if I delete the script from the logic_script and use a logic_auto to RunScriptFile).
Get rid of the semicolon. I doubt this is the problem but it could be.
Also try running the script in game using the ent_fire -> logic_script -> RunScriptCode "invertParent()" command. If it still comes up with the error, try reducing your code to just the function name and a printl("Test") inside of it in order to see if it is the actual script that is not being liked / syntax error.
function invertParent() {
printl("test")
}
FelixGriffin wrote:
Both of those give the same error message. This seems really weird. The script is in an instance, does that matter?
It shouldn't. Is your script prefixed with an @?
FelixGriffin wrote:
```
printl("SCRIPTFILE RUN");
printl(randomVar);```
Is that "randomVar" defined somewhere else? If not, then that last statement will cause a compile error.
I'm not sure if this causes your problem, (especially since you tried it with the super-simplified version as per Chicken's suggestion) but perhaps it's something to look into.