Please or Register to create posts and topics.

"The index does not exist."

Page 1 of 2Next

One of my maps includes a logic_script with a single function defined in it. A RunScriptCode calling the function brings up the error "The index [FUNCTION NAME] does not exist." Does anyone know what might cause this?

Falsi sumus crusto!

1. Your script is not in the Entity Scripts field in your logic_script
2. You are calling a function or value which is not stated inside the code
3. 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.

?????????????????????????????TWP Releases | My Workshop
Code: Select all
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.

Falsi sumus crusto!
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()

?????????????????????????????TWP Releases | My Workshop

Sorry.

"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).

Falsi sumus crusto!

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.

Code: Select all
function invertParent() {
   printl("test")
}
?????????????????????????????TWP Releases | My Workshop

Both of those give the same error message. This seems really weird. The script is in an instance, does that matter?

Falsi sumus crusto!
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 @?

?????????????????????????????TWP Releases | My Workshop

Yes. And it can be targetted just fine.

Falsi sumus crusto!

Hrmm... Only thing I can think of: Check the Entity Scripts field in your logic_script to see if you are referencing the correct script.

?????????????????????????????TWP Releases | My Workshop
Page 1 of 2Next