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
➜ General
➜ An addition of variables trigger/script
|
An addition of variables trigger/script
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Alisdair
Canada (3 posts) Bio
|
| Date
| Thu 24 Apr 2003 09:21 AM (UTC) |
| Message
| I've been reading file after file and post after post to try and find something relavent to my problem, but so far nothing. What I'm try to accomplish is a trigger or script that will add up 5 numbers and give a total.
[Str: 47 Int: 36 Wis: 32 Dex: 60 Con: 45]
Keep these stats? (Y/N)
What I want is to be able to add up those 5 numbers and get a total of at least 250. And I'd like it to simply send "N" to world if it gets anything less, but stop if it gets a total of 250 or greater. Any suggestions? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Thu 24 Apr 2003 11:31 AM (UTC) Amended on Thu 24 Apr 2003 11:32 AM (UTC) by Nick Gammon
|
| Message
| Yes, you can do that easily enough with one trigger. This trigger below uses a regular expression to match on your line, adds up the 5 figures, and if it reaches 250 sends Y and disables itself, otherwise it sends N.
You need a recent version of MUSHclient, as it uses inline scripting, version 3.39 is now released.
<triggers>
<trigger
custom_colour="2"
enabled="y"
match="^\[Str\:\s+(\d+)\s+Int\:\s+(\d+)\s+Wis\:\s+(\d+)\s+Dex\:\s+(\d+)\s+Con\:\s+(\d+)\]$"
name="initialtest"
regexp="y"
send_to="12"
sequence="100"
>
<send>if %1 + %2 + %3 + %4 + %5 >= 250 then
send "Y"
enabletrigger "initialtest", 0
note "Found it!"
else
send "N"
end if</send>
</trigger>
</triggers>
Make sure scripting is enabled or the script won't do anything. :) |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Alisdair
Canada (3 posts) Bio
|
| Date
| Reply #2 on Thu 24 Apr 2003 03:02 PM (UTC) |
| Message
| | Wow, thanks a bunch Nick :) | | Top |
|
| Posted by
| Alisdair
Canada (3 posts) Bio
|
| Date
| Reply #3 on Thu 24 Apr 2003 03:40 PM (UTC) Amended on Thu 24 Apr 2003 04:44 PM (UTC) by Alisdair
|
| Message
| Ok, this is weird for whatever reason, but with the trigger, the output gets a little screwy, and ends up that the trigger stops.
Here's what I mean:
[Str: 44 Int: 40 Wis: 38 Dex: 50 Con: 43]
N
Keep these stats? (Y/N) [Str: 44 Int: 47 Wis: 40 Dex: 53 Con: 45]
That happens right after the trigger fires. Any solutions? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #4 on Thu 24 Apr 2003 08:57 PM (UTC) |
| Message
| You need to modify the trigger match text slightly to allow for optional extra stuff at the start, like this:
^.*\[Str\:\s+(\d+)\s+Int\:\s+(\d+)\s+Wis\:\s+(\d+)\s+Dex\:\s+(\d+)\s+Con\:\s+(\d+)\]$ |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #5 on Thu 24 Apr 2003 08:59 PM (UTC) |
| Message
| You probably need to make sure the trigger is enabled next time, by either taking out the line that disables it (and hoping that text never appears during game play), or matching on something that appears right at the start, eg. "Enter you character name") and making another trigger that enables it.
It would need to do this:
enabletrigger "initialtest", 1 |
- 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.
18,539 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top