help with auto movement, and a couple of questions on scripting

Posted by Acton on Tue 01 Apr 2008 10:25 PM — 6 posts, 24,111 views.

#0
Hello,
I'm working on a movement script. that when it sees the line of text "You are now running along the edge of Oakdale Forest." it will change a variable, to either east, or west, and call a move function that will trigger something like west, or what ever the variable is set to.
I understand the basics of vbs, just can't figure out how to get this working.
Also, I'm blind, and using a screen reader. the hlp file that comes with mushclient isn't very accessible, and the scripting tutorial that uses pictures doesn't work the best.
Is there a way I can see what all functions are located in the world, and any other mushclient namespaces?
Last, I know more php than vbs. how hard is it, for me to get php working? I've seen a link here somewhere for a dll, but it's never worked well for me--basically it doesn't work. :)
Australia Forum Administrator #1
This site makes a fairly big effort to be accessible to people using non-standard web browsers. Hopefully the forum is reasonably easy to use for visually impaired users.

However having said that, there is the saying "a picture is worth a thousand words", so in a few places, particularly the scripting introduction, I illustrated my tutorial with some graphics. A quick browse of that page seems to show that it is fairly readable without the graphics, but I will review it and see if I can explain in the text anything that might have been purely visible in a graphic.

You seem to be ambivalent about whether to use VBscript or PHP, may I recommend Lua? That is supplied built-in to MUSHclient, and is therefore somewhat more reliable than any language that uses the Windows Script Interface.

The syntax of Lua is similar to VBscript, and similar for that matter to PHP as well.

It is easier to get help on Lua, because everyone has Lua installed, and a lot of the more serious scripters on the forum are using it as well (not all, of course, my apologies to anyone this appears to be insulting).

Quote:

Is there a way I can see what all functions are located in the world, and any other mushclient namespaces?


All functions are listed here:

http://www.gammon.com.au/scripts/function.php

The help file should be useable, I am not sure why it is a problem to access it.

However the identical information is available from this site at this URL:

http://www.gammon.com.au/scripts/doc.php

This is generated from the same database, and is therefore identical to the help file. It is probably better to use the help file (or documentation link) because related functions are grouped there as cross-references.

If the online help is too slow to access, you can download the help file as HTML files, from this link:

http://www.gammon.com.au/files/mushclient/mushclient_help_4.15.zip

This effectively has each help topic as one HTML file, so you can view them in your web browser offline. This forum post describes it, along with some helpful scripts for doing searches:

http://www.gammon.com.au/forum/?id=7796

Now back to your original question. I suggest a trigger that matches the relevant text, and in the trigger you can do "send to script". In the script you can use the Send function to send a command to the MUD (eg. to go west), and use SetVariable to set a variable. You can use GetVariable to query a variable.
Australia Forum Administrator #2
Lua (and some others) is a case-sensitive language, so it may be hard to get the capitalization right if the words are being read out to you, however this may help:

  • The Lua syntax itself relies upon all lower-case words. Thus, words like "while", "repeat", "end" and so on are always all lower-case.
  • MUSHclient functions (those you call from your script) however are usually capitalized with each "word" being started with an upper-case letter. For example, "Note" starts with a capital N and the rest is lower-case. However ColourNote has both the "C" and "N" capitalized, as it is really "colour" followed by "note".

    As another example, AddTimer has a capital "A" for Add and a capital "T" for Timer.
  • As I am Australian, I use English spelling, so the word Colour is spelt C-O-L-O-U-R, note the "U" in the middle.


#3
Hello,
thanks for the expediant reply.
I think I understand how this should work, but have trouble understanding how the "send to script," function will link to my script. will it send an argument to the function? I think, as I don't have time to learn lua with some current projects, I'll just keep going with vbs, for now. Anyway, is there some sorta sample on how to send to script, and make it change? Also, on my connect event, I have a line of code that looks like:
world.send("load myame, mypass")
it doesn't like that(using vbs). Any ideas?
Thanks,
Australia Forum Administrator #4
I suggest you take a look at the scripting introduction page:

http://www.gammon.com.au/scripting

I have finished amending it now to call out the graphics in text form as well, so you should be able to read it OK.

My quick reply is, if you use "send to script" then the "send" box is the script (hence, send to: script). The "send to" combo-box tells MUSHclient where to send whatever you have in the send box to. It might be the MUD (thus it effectively becomes input to the MUD), the output window, as a note to yourself, the script engine (for scripts), and various other options, like to a notepad window.

However if you want to put scripts in a separate script file (the name of which is in the scripting configuration dialog), then you can leave the "send" box blank, and instead put the function name to be called into the Script box.

The script function is called with three arguments: name of the trigger or alias, the matching line, and the wildcards array. Thus the first wildcard is the wildcards array, indexed by 1.

Quote:

I have a line of code that looks like:
world.send("load myame, mypass")
it doesn't like that(using vbs).


VBscript has a rather strange syntax rule that if you call a function without getting a return value, you must not use brackets. However if it returns a value, you must.

Thus, your line should read:


Send "load myame, mypass"


I have omitted the brackets. I have also omitted "world." as that is unnecessary and just is extra typing.
#5
thanks. I'll take a look at that. :)