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 ➜ General ➜ Trigger/Variable Capture Problems

Trigger/Variable Capture Problems

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


Posted by Xerakon   USA  (5 posts)  Bio
Date Fri 11 Apr 2014 01:08 AM (UTC)
Message
Hello everyone!

Just recently have begun converting over from CMUD to MUSH! But I am having a ton of problems trying to get things going here. Although I have scoured the forums, perhaps I need abit more babying.


You have 780 (780) hit points and 1623 (1623) social points.


Is what I'm trying to convert to variables so I can put in health bars and such. These values should be the variables of hp, maxhp, sp, and maxsp.

Now, in the trigger editor, I have:


^You have (.*) ((.*)) hit points and (.*) ((.*)) social points.


Send box contains: %1

Send to: Variable
Variable: hp

But it sends nothing to the variable. any ideas why or what I need to do to get it to start capturing?

Thanks!
Top

Posted by BlackGuard   USA  (12 posts)  Bio
Date Reply #1 on Fri 11 Apr 2014 02:54 AM (UTC)
Message
You want to change the regex a bit as it's not capturing I imagine due to the parenthesis not being escaped with \ use.

^You have (.*?) \((.*?)\) hit points and (.*?) \((.*?)\) social points\.$

OR if you want the regex more specific to numbers

^You have (\d+) \((\d+)\) hit points and (\d+) \((\d+)\) social points\.$

Try one of those.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Fri 11 Apr 2014 03:59 AM (UTC)
Message
BlackGuard is right about the parentheses.

Template:regexp Regular expressions
  • Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
  • Also see how Lua string matching patterns work, as documented on the Lua string.find page.

- Nick Gammon

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

Posted by Xerakon   USA  (5 posts)  Bio
Date Reply #3 on Fri 11 Apr 2014 12:57 PM (UTC)

Amended on Fri 11 Apr 2014 04:45 PM (UTC) by Xerakon

Message
Okay. I've fixed the trigger capture portion. However, the variable is still not filling. I'm thinking that I am incorrectly filling out the wizard.

See the below image.

http://i108.photobucket.com/albums/n24/Xerakon/SWMud/triggerprob_zps6ca77509.png
Top

Posted by BlackGuard   USA  (12 posts)  Bio
Date Reply #4 on Fri 11 Apr 2014 04:11 PM (UTC)
Message
Hrm... That's not typically how I edit variables. But with your method, you have to make sure the variable is already created first.

Go to the variable tab and make sure that 'hp' is already added then the trigger should work.

How I normally do variables is through a script file. In that instance, I'd just set the trigger to send to script and in the send box put:

hp = "%1"
mp = "%2"
sp = "%3"
etc all in one trigger. But that sort of set up might be a touch complicated since it deals with a file outside of MUSHclient, I think.
Top

Posted by BlackGuard   USA  (12 posts)  Bio
Date Reply #5 on Fri 11 Apr 2014 04:22 PM (UTC)
Message
You also want to check off the box that the trigger is a regular expression.
Top

Posted by Xerakon   USA  (5 posts)  Bio
Date Reply #6 on Fri 11 Apr 2014 04:50 PM (UTC)
Message
Here's what it's currently looking like. Still not filling in the variables. And the variables are already created.

Trigger line:
^You have (\d+) \((\d+)\) hit points and (\d+) \((\d+)\) social points\.$


Send box:
hp = "%1"
maxhp = "%2"
sp = "%3"
maxsp = "%4"


send to: Script

Enabled is checked.
Regular Expression is checked.
Top

Posted by BlackGuard   USA  (12 posts)  Bio
Date Reply #7 on Fri 11 Apr 2014 08:50 PM (UTC)
Message
Oh, the variables are there but there in a different section entirely if you're using my method.

MUSHclient variables are located in the variable table and are referenced with stuff like this in triggers:

SetVariable ("hp", "%1")
SetVariable ("mhp", "%2")
SetVariable ("sp", "%3")
SetVariable ("msp", "%4")

So you'd use the above. The example I listed earlier with stuff like:

hp = "%1"
mhp = "%2"

etc That would only go in the trigger if you were referencing variables in the matrix (I think that's the term) created OUTSIDE of MUSHclient. Like if you wanted, you could open notepad and write your entire system in there with variables and functions. And then use MUSHclient to manipulate the information in this manner. But that can be overly complicated and confusing. So just use the SetVariable stuff for now.
Top

Posted by Xerakon   USA  (5 posts)  Bio
Date Reply #8 on Fri 11 Apr 2014 10:04 PM (UTC)

Amended on Fri 11 Apr 2014 10:15 PM (UTC) by Xerakon

Message
Okay, got it to work using your coding there! Awesome, thanks so much!

In CMUD, there were short-cuts. is there anything like that in MUSH pertaining to triggers/variables?

For example, this trigger:

You have &hp ~(&maxhp~) hit points and &sp ~(&maxsp~) social points.


This would have automatically created the variables and filled them with values.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #9 on Sat 12 Apr 2014 05:29 AM (UTC)
Message
No, nothing like that which automatically fills variables.

I'm a little opposed to things that "automagically" do things for you. I somewhat prefer a procedural approach where you can see what is happening.

- 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.


36,727 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.