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 ➜ Tips and tricks ➜ Triggering below a certain number?

Triggering below a certain number?

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


Posted by Zeno   USA  (2,871 posts)  Bio
Date Sat 11 Oct 2003 06:07 PM (UTC)
Message
If my HP drops below a certain amount, lets say 1000, is there a way to use a trigger to send a result, or would I have to use scripting? Either way, could I get some ideas how to get this set up?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Sat 11 Oct 2003 08:31 PM (UTC)
Message
depends on what your prompt is...
but, for the hp youd use:
\d{1,3}
(this is as a regular expression)
that would match on 1 to 3 digits, which would be from 1-999

More info can be found at this thread (at the end it talks about not using scripting, just a regexp)

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=702

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #2 on Sun 12 Oct 2003 01:09 AM (UTC)

Amended on Sun 12 Oct 2003 02:35 AM (UTC) by Zeno

Message
What if the variable has a comma in it? Would that be treated as a extra digit?

Alright, I get this error:

Error number: -2146827838
Event:        Execution of line 1 column 1
Description:  Wrong number of arguments or invalid property assignment: 'CLng'
Line in error: 

Called by:    Immediate execution


Its:

if CLng (%1) < 5000 then
  Send "down"
end if

%1 is the first * in the trigger, which is HP.

[EDIT2] Hmm, looks like its having trouble with commas. How would I get this to work if the variable (HP) has commas?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #3 on Sun 12 Oct 2003 05:31 AM (UTC)
Message
Try:

if clng(replace("%1",",","")) > 5000 then

You have to place "" around things like %1 in commands used with 'send to script'. This is because VBScript would interpret the following like so:

%1 = Fred

becomes>

if Fred = "Fred" then ...

In other words the %1 directly substitutes in the script and VB thinks you are asking it to compare a VB 'variable' called Fred, not the value. In your case you are probably getting something like:

HP: 1,000

which VB turns into:

if Clng(1,000) < 5000 then

This 'would' work without the comma, since it is a number, but it isn't a good idea to get into the habit of expecting it to work. ;)
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #4 on Sun 12 Oct 2003 05:20 PM (UTC)
Message
Ah, yeah, just needed to allow it to see commas, I see. I got it working how I wanted it to, thanks.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
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.


16,486 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.