help with a bit of code:

Posted by Acton on Thu 01 May 2008 11:45 PM — 4 posts, 18,705 views.

#0
Hello,
I've got the following error:
[string "Trigger: "]:5: '=' expected near 'direction'
and the code is:
world.send "say to imp perch"
world.send "ff"
world.send "ff"
world.send "ff"
dim direction
direction = world.GetVariable("dir")
if (dir = "east") then
world.send "east"
else
world.send "west"
end if
Any ideas why this is not working?
Thanks,
USA #1
Well, just glancing at it, I notice you're using dir instead of direction in the one place. Also, which language is this in?
#2
hello,
Dir is the variable stored within mush. I'm getting that var with my script.
and it's in vbs.
Thanks,
#3
First, you have a mistake in the script.

dim direction
direction = world.GetVariable("dir")


This is saying "declare a VB variable called 'direction' and place the contents of the Mushclient variable 'dir' in it". But in the next line, you are using a 'dir' variable:

if (dir = "east") then


This is not the same as the Mushclient variable 'dir', this is an unknown VB variable 'dir', so the direction will never be east. This line should be:

if (direction = "east") then


Second, this script gave me no errors, no matter if I placed the code in a script file or in the trigger "Send" box (with "Send to: Script" enabled). Are you sure you selected "VBScript" in the script configuration screen? It's set to Lua by default.