Variables for MUSHclient

by Talnar

Back to Mechanic's Corner.

Talnar2007-06-20 15:18:20
Now, back on Nexus, I used to set up some variables for my vials so I could easily refill them, such as: vial12234 would be health1, so instead of doing: REFILL VIAL 12234 FROM HEALTH, I could just do: REFILL HEALTH1 FROM HEALTH. It makes everything easier for me.

Well, I've decided to try out MUSHclient, and I've tried to do the same thing there, only I don't have a clue as to what I'm doing. Could someone please help me out a bit? Thanks greatly!

Edit: Oops! Forgot to ask this. Is there a pausing or waiting command in MUSHclient? Just curious. Thanks!
Talnar2007-06-20 15:55:23
Bump...
Unknown2007-06-23 16:14:13
You can do it the same way in MUSHClient. Config window->Scripting->Variables holds all the variables defined. Make a new one, name it HealthVial, set the corresponding value and you're done. Whenever you need to access this value from your script, you can invoke GetVariable("HealthVial"). For example, /Note(GetVariable("HealthVial")) to print the value in the MUD window.

There's a pause, yes. Pause(true) will pause the world for you, but I think that's not exactly what you want, so I suggest you read the help on Timer objects in MUSHClient.
Nerra2007-07-11 16:39:41
Hrm, what's wrong with this? It's in a timer and I can't figure this out
if getvariable ("sap") = "1" then
send "sap @target"
end if

Then I read this and tried...
if getvariable ("sap") = "1" then
send "sap (getvariable(targer))"
end if

What's wrong? Why won't it work?
Simimi2007-07-11 16:51:30
your thing is called target and you put (targer)?

EDIT: Also there are loads of threads that answer both of your issues already, in the mechanics section.
Unknown2007-07-11 16:55:49
QUOTE(Nerra @ Jul 11 2007, 12:39 PM) 424700
Hrm, what's wrong with this? It's in a timer and I can't figure this out
if getvariable ("sap") = "1" then
send "sap @target"
end if

Then I read this and tried...
if getvariable ("sap") = "1" then
send "sap (getvariable(targer))"
end if

What's wrong? Why won't it work?



The first one would fail if you forgot to check the "Expand variables" option, and may not work inside quotes.

The second needs to be outside the quotes and spelled correctly.

(Assuming VBS and not Lua..)
CODE
if getvariable ("sap") = "1" then
  send "sap " & getvariable(target)
end if
Nerra2007-07-11 17:25:29
Oh I just retyped those. I spelled it right. There is no "expand variable" box in Timers in MUSHclient... When I do this:
CODE
send "sap " & getvariable(target)

It just sends "sap" but no target....
Unknown2007-07-11 17:34:06
You have to put the variable name in quotations. I think you also can't use parenthesis, but after you put in the quotes it'll tell you if you can't. VBscript is really weird about when you can and can't use parenthesis.

Edit: And MUSH parses the @variables before sending anything to the script engine. So you could do something like GetVariable "@pickles" or GetVariable "%1". That's mostly in answer to Zarquan's comment, but it's really useful for regular expressions especially.
Nerra2007-07-11 17:40:07
Oooh,
CODE
send "sap " & getvariable ("target")

works. Thanks Req!!
Unknown2007-07-11 17:40:43
Okay. I use Lua, and I hate VBS, so my guess was off. You don't use the parentheses in VBS. smile.gif
Unknown2007-07-11 17:53:20
You have to do it sometimes. There was an article in the Microsoft Knowledge Base. I'll edit it in if I find it.