Error running script and evaluating expression help (Solved)
ShadowsEdge19
01 Sept 2017, 15:53The error I get is:
Error running script: Error evaluating expression 'Some_Function2(player)': Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index
<function name="Some_Function1" parameters="player" type="boolean"><![CDATA[
bReturn = Some_Function2(player)
return(bReturn)
]]>
</function>
<function name="Some_Function2" parameter="player" type="boolean"><![CDATA[
bReturn = FALSE
// Something else that might change bReturn to TRUE
return(bReturn)
]]></function>
I also tried just doing the following but it didn't work:
return(Some_Function2(player))
mrangel
01 Sept 2017, 17:31Is this your actual code, or have you changed it to make something you can share?
My first thought would be that Some_Function2() collides with a function of the same name that you might not know about.
Alternatively, do you have an object named player? I've seen some pretty odd and inscrutable error messages when names are duplicated.
Try renaming the functions or variables, and see if that changes the error message.
I assume that the code you've commented out doesn't include a parameter named 'index' anywhere?
ShadowsEdge19
01 Sept 2017, 18:29Nope no 'index' variable, fairly certain its a unique function but I'll double check.
Also I have player as the main playable object and I don't name it differently when I pass through to functions to make it easier to remember.
The Pixie
01 Sept 2017, 18:39You can get an error like that if the number of parameters does not match. It looks fine in the code you posted, but if you have changed it for the forum, it might be worth checking.
hegemonkhan
01 Sept 2017, 23:32(filler for getting my edited post, updated/posted)
the 'index' Attribute is an internal VARIABLE of quest for how the underlying code of quest works with handing Functions and/or whatever else is involved with them. Something is wrong/going-wrong with your code and quest can't do the function because of it, this is the error you're seeing.
Also, try changing your VARIABLES (Variable and Parameter)' names, as you might be causing a conflict with these built-in VARIABLES, see below for example to try:
'player' and 'return' are built-in stuff and since you used custom Variable and Parameter that uses these, you might be getting a conflict and/or parsing confusion.
(P.S. the 'CDATA' tags aren't needed unless you want/need to use the '>' and/or '<' symbols for scripting: greater than '>', lesser than '<', greater than or equal to '>=', lesser than or equal to '<=', and not-equals-alternative '<>', operations. Otherwise quest will see them as tags, and thus cause syntax errors)
<function name="Some_Function1" parameters="playable_character_A1_parameter" type="boolean">
b = Some_Function2 (playable_character_A1_parameter)
return (b)
</function>
<function name="Some_Function2" parameter="playable_character_A2_parameter" type="boolean">
// example only:
b = false
if (playable_character_A2_parameter = player) {
b = true
}
return (b)
</function>
// scripting example:
MY_VARIABLE = Some_Function1 (player)
// MY_VARIABLE = true
MY_VARIABLE = Some_Function1 (HK)
// MY_VARIABLE = false
ShadowsEdge19
02 Sept 2017, 07:49Nevermind I found the issue, my 2nd function had "parameter=" not "parameters=" which caused that error.
hegemonkhan
02 Sept 2017, 08:51wow... I totally missed that... hehe
(seriously, this holds so true as just demonstrated here lol: 90% of the time, it's some stupid small single typo/mistake, that is the causing the problem with your code, instead of a problem with the entire design/logic/operations/actions of your code, people are more smart than they realize at coding/scripting, hehe)
(the hard part is finding/noticing that stupid small single typo/mistake... lol. As, you don't know, what is the type or what is it, of your stupid small single mistake/typo: is it a missing 's' on parameters="blah", or is it a missing '}' or '>' or '/' somewhere, or you typo'ed a VARIABLE somewhere: game.turn vs typo: game.tunr, or is it... etc etc etc: when you don't know what you're looking for, it's hard to find it, even if you're looking for some stupid small typo/mistake... it's hard to notice them... you really have to take an entire minute on each word/part of your code, making sure it's correct... to be able to notice stupid small mistakes/typos, due to how your brain functions: one of the main purpose of the brain is to make sense of a complex/confusing world and its information overload, which the knowledge of this brain functionality can be used against the brain, which we call as "optical illusions" via optical cues to the brain and also other various non-optical types of brain trickings/deceptions as well)
this is why I myself hate using plurals for any/all of my naming/labeling of things, for my naming/labeling convention/system. As I just can't remember whether I have an 's' at the end or not of things. So, instead of using 'game.turns' for example, I just use 'game.turn', as this way I don't have to remember if something is named/labeled as plural (has an 's' at the end) or not (NO 's' at the end), when I have everything as non-plural (NO 's' at the end).
fortunately, I've created enough Functions with Parameters, that I remember its signature/header syntax is plural for it:
// it's a lowercase 's' in actual code syntax, but I'm just upper-casing it below to emphasize that there's the 's' on it:
// NO syntax error (excluding that it's wrongly an upper case 'S', as I mentioned above):
<function name="example_function" parameterS="blah">
</function>
// syntax ERROR:
<function name="example_function" parameter="blah">
</function>