Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ VBscript ➜ IFs and scripting

IFs and scripting

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Caeser   (22 posts)  Bio
Date Sat 09 Jul 2005 02:03 AM (UTC)
Message
Hi I am new to MUSHclient and scripting.
I don't have any scripts done or started for that matter, and was wondering:

How would you go about doing embedded if statements?
Also, how would you go about making a lot of triggers with scripting? I am trying to have a trigger set a variable, and then activate that large IF statement, and then when the IF statement detects the variable, it'll do what I want it to do, and then shut off the variable?

Sorry for asking for help on what I hope is something easy to do.
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #1 on Sat 09 Jul 2005 02:51 AM (UTC)
Message
It's easier to answer questions like this when you provide a concrete example. If you give messages from your game and describe what should happen for that particular scenario, we can give you advice on how to script the client to do just what you want.
Top

Posted by Caeser   (22 posts)  Bio
Date Reply #2 on Sat 09 Jul 2005 01:15 PM (UTC)

Amended on Sat 09 Jul 2005 03:50 PM (UTC) by Caeser

Message
Okay, I'll give the examples:
The MUD I play is Achaea, so I am hit with 2 venoms.
Now I can't eat the cure for both at once, since you can only eat 1 herb at a time, so then I have to wait until getting a message saying you can eat another herb.

So I am hit with:
^Hmmmm. Why must everything be so difficult to figure out?$

and

^Your body stiffens rapidly with paralysis.$

The first message I want to set to variable Stupidity and the second to variable Paralysis.

I want to cure the more important one first, so I want to cure the stupidity, and then when I can eat again cure the paralysis. For other MUD clients I have used, this is obtained by use embedded IF statements...but I could never get them to work. If there is another, easier way of doing this (I do have a lot more variables and messages then these 2, but I only picked these two as an example) with MUSHclient? If so or if not, can you explain how I would do this?
Top

Posted by Caeser   (22 posts)  Bio
Date Reply #3 on Sat 09 Jul 2005 04:16 PM (UTC)
Message
Also before I forget, how *DO* you start scripting? Can you just do it in a Wordfile? And if you can, can you just save it to the type of file you need?
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #4 on Sat 09 Jul 2005 07:28 PM (UTC)
Message
You create a script file just in any old text editor, and just save it as a vbs (since youre using VBScript). Mushclient has an internal notepad which you can use as well. You enable scripting in the script configuration screen (game > config > scripting). Make sure it's set to VBScript, and make sure it's enabled.

The 'new' (although it's been around for a while) way of scripting is to not use a script file. You can embed the script commands straight in the items (trigger/alias/timer) send text (and set the 'sendto' value to script).

You can take a look at all of the script functions (those are things you can call in your script that will do things with mushclient) from the link at the top of the mushclient forum (list of inbuilt script functions).

However, I suggest you take a look at the documentation (the new one, so either download the new help file, or view it online):
http://www.gammon.com.au/scripts/doc.php?general=scripting
it will get you started and explain all the nuances.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Caeser   (22 posts)  Bio
Date Reply #5 on Sat 09 Jul 2005 10:14 PM (UTC)

Amended on Sat 09 Jul 2005 10:18 PM (UTC) by Caeser

Message
Okay, 3 things...
1) That documentation page *REALLY* helped. It cleared up a lot of questions.

2) But, in the documentation it says when I script triggers I need to have 3 arguments: the text to match, the
command(s) it does, and then the wildcards.
I don't quite understand what that means though

3) One more question about the documentation and scripting in general: Why do I need to define error codes in my scripts?

Thanks, knowing what I know now, it'll really help with making the script I want for myself.
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #6 on Sun 10 Jul 2005 12:23 AM (UTC)
Message
Defining those constants (error codes and flags) aren't really important, Basically, if you look at the bottom of each script function (on the scripting documentation page) it will tell you what it returns (0 is Ok, etc) defining those error codes allows you to check the return against eOk instead of 0 (or whatever they actually are). They aren't necessary, but sometimes can help.

The three arguments (for when you call subroutines in triggers) are Name, Line, and Wildcard, youll see this a lot:
Sub SomeRoutine (sName, sLine, aryWild)
... sub routine here
End Sub

The triggers (and aliases) pass those arguments (the name of the trigger/alias that called the routine, the line it was called from, and then an array of the wildcards that were matched). Timers only send the name (so your subroutine has to be different if being called by a timer).

If you use the built-in scripting (when you put the script in the send box of the trigger/alias) you don't need to worry about that stuff, which is a big plus (you can just use the wildcard match things like %1 %2, and you can get the full like with %0) for normal cases (but if you want to have multiple triggers do the same thing, you have to type them all out). Of course, you could always call a subroutine from the embedded scripts.
Putting the scripts into the triggers themselves makes creating scripts a lot easier, since you dont have to open/edit/save/reload the script file each time you make a change.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Caeser   (22 posts)  Bio
Date Reply #7 on Sun 10 Jul 2005 04:20 AM (UTC)
Message
Okay, thanks...
Now for my (hopefully) last question for a while:

I want to do one long IF statement, filled with embedded IFs. Now, to call an IF statement that long, do I need to make it a script and have each trigger that sets a variable in the statement activate the script? And if so, how do I activate the script? I am a little unclear as to doing that.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


25,748 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.