ERROR: BAD VARIABLE NAME?
NeverwinterWights
Member Posts: 339
Perhaps someone can help me out and figure out why the following script keeps giving me an "ERROR: BAD VARIABLE NAME". It's originally part of a separate library but to test it out I put it in a separate script on it's own and it's still giving me the error. There is literally nothing else in this script:
It's specifically the perameter "string sLanguage". If I change it to "string sLanguag" (no e) it compiles fine.
void AddLanguageToLanguageArray(object oDBItem, string sLanguage) { int iLanguage = 1; string sCheck = GetLocalString(oDBItem, "LANGUAGE" + IntToString(iLanguage)); while (sCheck != "") { iLanguage++; sCheck = GetLocalString(oDBItem, "LANGUAGE" + IntToString(iLanguage)); } if (sCheck == "") SetLocalString(oDBItem, "LANGUAGE" + IntToString(iLanguage), sLanguage); } void main() { }
It's specifically the perameter "string sLanguage". If I change it to "string sLanguag" (no e) it compiles fine.
0
Comments
What's also wierd is I typed sLanguage as slanguage in the function header but didn't change the reference to the var in the last line of the function to match it, and it compiles fine.
Wierd!
Indeed. I guess in the meantime I'll just change that parameter to something else but it certainly is curious.
You can see that if you double-click the sLanguage in your script. Apparently it's not allowed to re-define variables defined in nwscript.nss.
That also explains why it compiles if you change the header. But of course in your function then the sLanguage from nwscript.nss would be used and not your parameter slanguage.
Ah gotcha. I was thinking it might be something already defined but it was the first time I'd seen that particular error. Also...why did I never know that you can double click things like that in the script until literally just now? Learn something new every day!
Thank you.