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 ➜ I am very new to using client triggers, alias's, timers, etc.

I am very new to using client triggers, alias's, timers, etc.

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


Pages: 1  2 3  

Posted by SdwSkr   (12 posts)  Bio
Date Reply #15 on Mon 11 Aug 2014 04:48 AM (UTC)
Message
Ok so better word for what I was meaning is scriptings was used to create the triggers.... Am I correct on that?
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #16 on Mon 11 Aug 2014 05:05 AM (UTC)
Message
Think of triggers as scripting on the fly. They do the same things, scripts are simply in a preset file that can't be directly edited once it's loaded by MC and in use by the client. Triggers are small bits of editable script you can change as your needs on the MU* change.

Oh, Nick, when you get around to checking in here again, I'm using 4.94 now (was 4.84) and still getting that error where it expects = near EnableTimer

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by SdwSkr   (12 posts)  Bio
Date Reply #17 on Mon 11 Aug 2014 06:25 AM (UTC)
Message
Ahh I see, well I know nothing about scripting... i dont understand how a script for a trigger to be fired would be written, nothing of the sort, if someone could kindly point this nood in a good starting space to learn that would be great, so i can start putting scripts in to my mud to do the things i want....since I started this post I have been doing all sorts of reading, including reading from Nicks scripting guide...
*Sighs Greatly*
Would love to know more...
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #18 on Mon 11 Aug 2014 08:35 AM (UTC)
Message
Meerclar said:

Ok, not sure what I've got wrong with this, documentation says it should work.


sleep
EnableTimer("manacheck", true)


...


wake
EnableTimer("manacheck", false)
else
break
endif



Where did "sleep" and "wake" come from? That's not documented anywhere. If they are function calls they need brackets, eg.


sleep ()

- Nick Gammon

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

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #19 on Mon 11 Aug 2014 08:36 AM (UTC)
Message
In this case, those are direct mud commands

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #20 on Mon 11 Aug 2014 08:38 AM (UTC)
Message
SdwSkr said:

ok that is where I am lost, how do I know what to set for a variable and how do I set it all up?


Watch those videos, it should become clearer.

You establish some "trigger" event, like something coming from the MUD.

When that happens you do stuff. It's hard to explain better, but you might say that if you see:


You are thirsty.


You make a trigger that notices that phrase and sends:


drink water


Now the devil is in the details. Maybe the message is not exactly "You are thirsty." and maybe that's not how you drink. But that's the basic idea.

- Nick Gammon

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

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #21 on Mon 11 Aug 2014 09:19 AM (UTC)

Amended on Mon 11 Aug 2014 09:47 AM (UTC) by Meerclar

Message
Progress, at least a little bit - I found what was wrong with my sleep trigger. Turns out that mixing mud commands and script calls isn't quite as simple as I thought and I needed to use Send ("sleep") instead of just the command ... that's what happens when I stray out of my comfort zone, I have to learn new things lol.

Still tweaking the other half of the attempt at figuring out how to do this request, looking like it might not be workable off the prompt the way I tried to do it though. I'm thinking converting part of score to regex and working it that way might be a better option.

*edit* Yeah, def not firing on the prompt for this so back to the drawing board there.

The relevant line from score is
||||   Int:  17( 19)    Wis:  15( 18)   :   Mana:       133   /   133      ||||

The spacing I expect will always be like that, the numbers will of course be different.

My current attempt at converting that to a trigger is

<triggers>
  <trigger
   enabled="y"
   match="^\|\|\|\|   Int\:  *\( *\)    Wis\:  *\( *\)   \:   Mana\:       *   \/   *      \|\|\|\|$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>current = %5
max = %6

if "current" == "max" then
Send ("wake")
EnableTimer("manacheck", FALSE)
end</send>
  </trigger>
</triggers>


Finished version of the out of mana trigger:

<triggers>
  <trigger
   enabled="y"
   match="You don't have enough mana."
   send_to="12"
   sequence="100"
  >
  <send>Send ("sleep")
EnableTimer("manacheck")</send>
  </trigger>
</triggers>

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by SdwSkr   (12 posts)  Bio
Date Reply #22 on Mon 11 Aug 2014 03:45 PM (UTC)
Message
Ok I know how to set up triggers from that fire from the output the mud send but i cant figure out how to make this into a trigger.
Finished version of the out of mana trigger:

<triggers>
  <trigger
   enabled="y"
   match="You don't have enough mana."
   send_to="12"
   sequence="100"
  >
  <send>Send ("sleep")
EnableTimer("manacheck")</send>
  </trigger>
</triggers>

Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #23 on Mon 11 Aug 2014 04:11 PM (UTC)
Message
Copy from <triggers> to </triggers>, open the triggers menu in MC, hit paste. What you're seeing here is the raw xml that MC saves triggers and whatnot as. For what it's worth, my current manacheck timer is a 90 second score sent directly to the mud though the attempt to match on the line that has mana on it isn't quite right yet.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by SdwSkr   (12 posts)  Bio
Date Reply #24 on Mon 11 Aug 2014 05:02 PM (UTC)
Message
Say i wanna add one of my own timers to the xml code that is there, I go to my time name it in the label area and the delete the manacheck in between the <> and put timer label there? I hope you understand what I am meaning....
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #25 on Mon 11 Aug 2014 05:21 PM (UTC)
Message
Yep, that's exactly how you'd handle that. You could also copy the enabletimer line and just change the name to add a 2nd timer.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by SdwSkr   (12 posts)  Bio
Date Reply #26 on Mon 11 Aug 2014 06:10 PM (UTC)

Amended on Mon 11 Aug 2014 06:13 PM (UTC) by SdwSkr

Message
So I was reading all sorts of things last night on scripting, this is scripting a trigger to add a timer, if someone could add more help on writing my own scripts this would become so much easier for me to understand... yes i know this is all in xml coding but it is still a script none the less...
Top

Posted by Fiendish   USA  (2,555 posts)  Bio   Global Moderator
Date Reply #27 on Mon 11 Aug 2014 07:14 PM (UTC)

Amended on Mon 11 Aug 2014 07:15 PM (UTC) by Fiendish

Message
Quote:
if someone could add more help on writing my own scripts this would become so much easier for me to understand

If you asked more specific and detailed questions it would be much easier for us to offer suggestions. You have to help us help you by asking better questions.

As Nick suggested, watch the instructional videos.
Also read this: http://www.gammon.com.au/forum/?id=4777
Also read the FAQs: http://www.gammon.com.au/forum/?id=7794

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #28 on Mon 11 Aug 2014 07:23 PM (UTC)

Amended on Mon 11 Aug 2014 07:43 PM (UTC) by Meerclar

Message
Help me convert that line I posted earlier to a proper regex ;) I know the conversion I posted is wrong (solid foundation, bad numeric conversions) but I've always been horrible with regex conversions like that.

*edit*
It just occurred to me that converting that line to regex is only minimally necessary since it only needs to match on full mana and the stats won't change while sleeping. Provided there isn't a lot of gear changing going on, it should be possible to simply paste the line from score with full mana as the trigger to match to wake the sleeping caster and disable the associated timer. The only real benefit to the regex conversion at this point is not needing to change the trigger every time you gain a level or trade out a piece of gear that affects your mana pool.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #29 on Mon 11 Aug 2014 08:36 PM (UTC)

Amended on Mon 11 Aug 2014 08:37 PM (UTC) by Nick Gammon

Message
Meerclar said:

Help me convert that line I posted earlier to a proper regex ...


A nice read is here:

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.



   match="^\|\|\|\|   Int\:  *\( *\)    Wis\:  *\( *\)   \:   Mana\:       *   \/   *      \|\|\|\|$"


OK, to match 4 x | symbols you can use:


\|{4}


To match multiple spaces where the exact count isn't critical, just do:


\s+


There were a number of things wrong with your regexp, and the code. This version works better:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="(?x) ^ \|{4} \s+ Int: \s+ \d+ \( \s* \d+ \) \s+ Wis: \s+ \d+ \( \s* \d+ \) \s+ : \s+ Mana: \s+ (\d+) \s+ / \s+ (\d+) \s+ \|{4} $"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

current = tonumber ("%1")
max = tonumber ("%2")

if current &gt;= max then
  EnableTimer("manacheck", false)
end

</send>
  </trigger>
</triggers>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


I used the "extended" regexp syntax (?x) to allow me to put spaces between each main item.


^        --> start of line
\|{4}    --> 4 bars
\s*      --> zero or more spaces
\s+      --> one or more spaces
\d+      --> one or more digits
\(       --> literally a bracket
\)       --> literally a closing bracket
(\d+)    --> a "capture" group (capturing one or more digits)
$        --> end of line


You didn't have any capture groups. I have two so they become %1 and %2.

You shouldn't compare:


if "current" == "max" then


That will never be true. You mean:


if current == max then

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


115,958 views.

This is page 2, subject is 3 pages long:  [Previous page]  1  2 3  [Next page]

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.