Setvariable

Posted by Mannoman on Sun 21 May 2006 12:27 AM — 3 posts, 13,875 views.

#0
I am trying to make an alias to set a variable

set *

world.SetVariable("VarName", %1)

[string "Alias: "]:4: bad argument #2 to `SetVariable' (string expected, got nil)
stack traceback:
[C]: in function `SetVariable'
[string "Alias: "]:4: in main chunk

so ... what should I do?
Australia Forum Administrator #1
If %1 is the word "kobold", then you are doing:

world.SetVariable("VarName", kobold)

The variable kobold will not exist, thus it is nil, thus it is complaining you are using nil where you should have a string.

You want this:


world.SetVariable("VarName", "%1")
Australia Forum Administrator #2
There is also an option in triggers and aliases to "send to variable" so you can simply put %1 in the "send" box and send directly to the variable, whose name you specify in the alias dialog.

However I wanted to answer your actual question so you understood the change needed, in case that was part of a larger script.