Problem with variables

Posted by Laurelei on Tue 27 Dec 2011 01:07 PM — 10 posts, 30,971 views.

#0
I viewed the tutorial about variables, but when I try to use SetVariable similarly in the client (for Aardwolf) I get a runtime error. See below


Run-time error
World: Aardwolf
Immediate execution
[string "Command line"]:1: attempt to call global 'SetVariable' (a string value)
stack traceback:
[string "Command line"]:1: in main chunk
USA Global Moderator #1
You will have greater luck getting help if you actually show us what you did to get that error message.
Amended on Tue 27 Dec 2011 04:28 PM by Fiendish
#2
I typed \\\SetVariable ( mobname, Naga) in the command line of the client (where I enter my commands to move about the mud), just like in the tutorial. my scripting page shows the three backslashes as my script prefix.
#3
Actually, I typed it with quotes as well:

\\\SetVariable ( "mobname", "Naga")

Either way I get the error
Australia Forum Administrator #4
Can you try this?


\\\print (SetVariable)


You should see something like:


function: 018DBA48


(The numbers might be different).

I suspect you have assigned a string to SetVariable. Reloading the script environment (Game Menu -> Reload Script File) should help.
Australia Forum Administrator #5
Laurelei said:

I typed \\\SetVariable ( mobname, Naga) in the command line of the client (where I enter my commands to move about the mud), just like in the tutorial. my scripting page shows the three backslashes as my script prefix.


That is wrong anyway, because mobname and Naga will be treated as variables (not literals) and are probably nil. You need the quotes.
#6
Typing \\\print (SetVariable) gives me "unknown command, please check the helpfiles"--I think that's aard's message, not mush.
#7
That is wrong anyway, because mobname and Naga will be treated as variables (not literals) and are probably nil. You need the quotes.


Like I said, I did it with quotes with the same result.
USA Global Moderator #8
Laurelei said:
Typing \\\print (SetVariable) gives me "unknown command, please check the helpfiles"--I think that's aard's message, not mush.
I think that's not possible unless you disabled the script engine before that. Make sure the script engine is enabled, set to Lua, and that you typed it correctly.
Amended on Wed 28 Dec 2011 02:32 PM by Fiendish
Australia Forum Administrator #9
Well let's not thrash around.

First, doing something like this should work:


\\\print "hello"


If not, you don't have \\\ as your scripting prefix, or you don't have scripting turned on (or set to Lua).

Note that your scripting prefix must be the very first thing entered, a leading space means what you type just goes to the MUD.

Second, you may as well use the version that will work:


SetVariable ( "mobname", "Naga")


Third, if it says SetVariable is a string, it is because you made it so. Maybe you did this at some stage:


SetVariable = "mobname", "Naga"