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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ Little help please.

Little help please.

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


Posted by Metsuro   USA  (389 posts)  Bio
Date Thu 27 May 2004 09:06 PM (UTC)

Amended on Thu 27 May 2004 09:09 PM (UTC) by Metsuro

Message
Alright i have a 3 triggers to match a line that can vary, sometimes it has only one part, or two, or three. something like.

you see (a star|an asteroid|a comet) or
you see (a star|an asteroid|a comet),(a star|an asteroid|a comet) or even
you see (a star|an asteroid|a comet), (a star|an asteroid|a comet), and (a star|an asteroid|a comet)

what i want to do is, whenever theres a "an asteroid" to send to the mud, "stop" then set a variable Asteroids with plus one, well i would also like it to set 2 other varibles depending on what its gets, and no matter which order and such

Everything turns around in the end
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 27 May 2004 09:42 PM (UTC)
Message
For one thing, you could do that with one trigger. I gather they are regular expressions? Just use the "0 or 1" quantifier, or do it with squiggly brackets, like this:



<triggers>
<trigger
custom_colour="2"
enabled="y"
match="you see (?P&lt;a&gt;a star|an asteroid|a comet)(, (?P&lt;b&gt;a star|an asteroid|a comet)){0,1}(, and (?P&lt;c&gt;a star|an asteroid|a comet)){0,1}"
regexp="y"
send_to="2"
sequence="100"
>
<send>%%0 = %0
%%1 = %1
%%2 = %2
%%3 = %3
%%4 = %4
%%5 = %5
%%6 = %6
a = %&lt;a&gt;
b = %&lt;b&gt;
c = %&lt;c&gt;
</send>
</trigger>
</triggers>


If you try this out, it will match all three cases, and by using named wildcards the three things it finds are in wildcard "a", "b", and "c".

Then you could do something like this in your (send to) script:


if "%<a>" = "an asteroid" then
  asteroids = asteroids + 1
elseif "%<a>" = "a comet" then
  comets = comets + 1
elseif "%<a>" = "a star" then
  stars = stars + 1
end if

if "%<b>" = "an asteroid" then
  asteroids = asteroids + 1
elseif "%<b>" = "a comet" then
  comets = comets + 1
elseif "%<b>" = "a star" then
  stars = stars + 1
end if
 
' ditto for c



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #2 on Thu 27 May 2004 09:56 PM (UTC)

Amended on Thu 27 May 2004 10:17 PM (UTC) by Metsuro

Message
after adding this another of my alias, script doesn't work now wondering why

Error number: -2146827284
Event: Execution of line 1 column 5
Description: Expected ';'
Line in error:
sub OnStar(name, output, wildcs)

quick note i also get

Error number: -2146827256
Event: Execution of line 1 column 1
Description: Invalid character
Line in error:
%0 = The computer reports the presence of some debris
Called by: Immediate execution

Everything turns around in the end
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 27 May 2004 10:28 PM (UTC)
Message
Which scripting language are you using? It is more normal for JScript to report a missing semicolon.

Can you post a few previous non-blank lines too? Often error messages are caused by the previous line.

Or, if that is the first line, can you paste the entire alias here? Click the "copy" button on the alias list to do it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #4 on Thu 27 May 2004 10:30 PM (UTC)
Message
Whoops accidently switched to JScript

Everything turns around in the end
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #5 on Thu 27 May 2004 10:33 PM (UTC)
Message
and are you saying to make two triggers that use

<triggers>
<trigger
custom_colour="2"
enabled="y"
match="you see (?P&lt;a&gt;a star|an asteroid|a comet)(, (?P&lt;b&gt;a star|an asteroid|a comet)){0,1}(, and (?P&lt;c&gt;a star|an asteroid|a comet)){0,1}"
regexp="y"
send_to="2"
sequence="100"
>
<send>%%0 = %0
%%1 = %1
%%2 = %2
%%3 = %3
%%4 = %4
%%5 = %5
%%6 = %6
a = %&lt;a&gt;
b = %&lt;b&gt;
c = %&lt;c&gt;
</send>
</trigger>
</triggers>

but one to the output, and the other with the other information?

Everything turns around in the end
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #6 on Fri 28 May 2004 12:04 AM (UTC)
Message
No, that was just an example. Use that trigger, but replace the "send" text (which was just to debug the trigger) with the script example I gave.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #7 on Fri 28 May 2004 12:52 AM (UTC)
Message
any way to set it up to check for the comma befor and? it sometimes does not use it

Everything turns around in the end
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #8 on Fri 28 May 2004 07:09 AM (UTC)

Amended on Fri 28 May 2004 07:11 AM (UTC) by Nick Gammon

Message
Sure. Read the regular expression write-up, they help with this sort of stuff.

Remembering I had it set up so a whole phrase was optional, certainly a comma can be optional.

Simply putting in:

,?

Means zero or one comma. Or, using the method I had above, you could say:

,{0,1}

That still says "zero to one of the preceding thing". In this example the "preceding thing" is the comma symbol.

Or, you can have groups, eg.

(, ){0,1}

That is, zero or one of a comma followed by a space.

You can do all sorts of things like that. eg.

a{5,6}

Means 5 or 6 lots of "a", ie. "aaaaa" or "aaaaaa".

Or, this:

(nick){2,3}

This would be 2 or 3 lots of "nick", ie. "nicknick" or "nicknicknick".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Firgin   (15 posts)  Bio
Date Reply #9 on Sun 30 May 2004 01:31 PM (UTC)
Message
as we're on this "little help" subject, I need a little help myself, how do you make a timer expand variables?
-thanks
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #10 on Sun 30 May 2004 11:51 PM (UTC)
Message
At present timers cannot expand variables directly, although I will look at adding that. However you could do it with "send to script" and something like this:

Send "eat " & GetVariable ("foodtype")


- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


28,723 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.