"The index does not exist."

Avatar
FelixGriffin
2,680 Posts
Posted Jul 08, 2012
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?
Advertisement
Registered users don’t see ads! Register now!
Avatar
ChickenMobile
2,460 Posts
Posted Jul 08, 2012
Replied 5 hours later
  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.

Avatar
FelixGriffin
2,680 Posts
Posted Jul 09, 2012
Replied 14 hours later
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.

Avatar
ChickenMobile
2,460 Posts
Posted Jul 09, 2012
Replied 40 minutes later

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()

Avatar
FelixGriffin
2,680 Posts
Posted Jul 09, 2012
Replied 7 minutes later
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).

Avatar
ChickenMobile
2,460 Posts
Posted Jul 09, 2012
Replied 10 minutes later

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")
}
Avatar
FelixGriffin
2,680 Posts
Posted Jul 09, 2012
Replied 1 minute later
Both of those give the same error message. This seems really weird. The script is in an instance, does that matter?
Avatar
ChickenMobile
2,460 Posts
Posted Jul 09, 2012
Replied 2 minutes later

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 @?

Avatar
FelixGriffin
2,680 Posts
Posted Jul 09, 2012
Replied 8 minutes later
Yes. And it can be targetted just fine.
Avatar
ChickenMobile
2,460 Posts
Posted Jul 09, 2012
Replied 3 minutes later
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.
Avatar
HMW
806 Posts
Posted Jul 09, 2012
Replied 1 hour later

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.

Advertisement
Registered users don’t see ads! Register now!
Avatar
FelixGriffin
2,680 Posts
Posted Jul 09, 2012
Replied 15 minutes later
Sorry, there's one line at the beginning saying randomVar <- 0 (just to test if it runs, in which case there'd be a variable declared instead of an empty table).