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 ➜ Plugins ➜ Need help with a simple trigger.

Need help with a simple trigger.

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


Pages: 1 2  

Posted by Deacla   USA  (42 posts)  Bio
Date Mon 05 Jul 2010 05:29 PM (UTC)

Amended on Mon 05 Jul 2010 05:34 PM (UTC) by Deacla

Message
How can i create a trigger for this string:

     a glossy lime scroll (new)

That appends the name of the spell that is scribed on that scroll just behind the word 'scroll' and in front of '(new)', thusly:

     a glossy lime scroll ARMOR (new)

I would like this effect to be in-line in the output window without messing with the lines default colors. As i have it now, i have made a simple trigger that just sends a note to the output window with the spell name but it is on the next line and becomes annoying.

A gnomish miner's bag contains:
     a glossy lime scroll (new)
           ARMOR
(  2) an unusual swamp flower
     a nightshade mushroom
     an ivory-yellow papyrus scroll (new)
           BLINDNESS
     a charcoal lambskin scroll (new)
           REVEAL
( 20) a blackjack voucher notated with a little '500' (new)
(  7) a copper-colored scroll (new)
           IDENTIFY

Any help is greatly appreciated.



edit: small grammar fix

--

working way to hard to play
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #1 on Mon 05 Jul 2010 06:00 PM (UTC)

Amended on Mon 05 Jul 2010 06:01 PM (UTC) by WillFa

Message
Try This... It shows the concept, it compiles, but I didn't actually test it out. (Coded on faith!)



<triggers>
  <trigger
   enabled="y"
   match="^(?: \([\s\d]+\))?\s+a ([\w\s-]+) scroll \(new\)$"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  <send>ScrollTypes = {
["glossy lime"] = "ARMOR",
["ivory-yellow papyrus"] = "BLINDNESS",
["charcoal lambskin"] = "REVEAL",
["copper-colored"] = "IDENTIFY",
}
if ScrollTypes["%1"] then
  ColourNote(TriggerStyleRuns[1].textcolour, TriggerStyleRuns[1].backcolour,
     "a %1 scroll " .. ScrollTypes["%1"] .. " (new)")
else
  ColourNote(TriggerStyleRuns[1].textcolour, TriggerStyleRuns[1].backcolour,
     "%0")
end</send>
  </trigger>
</triggers>
Top

Posted by Deacla   USA  (42 posts)  Bio
Date Reply #2 on Mon 05 Jul 2010 06:46 PM (UTC)
Message
I changed the code a little to this:

<triggers>
  <trigger
   enabled="y"
   match="^(?: \([\s\d]+\))?\s+([\w\s-]+) scroll \(new\)$"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >

<send>ScrollTypes = {
	["a glossy lime"] = "ARMOR",
	["an ivory-yellow papyrus"] = "BLINDNESS",
	["a charcoal lambskin"] = "REVEAL",
	["a copper-colored"] = "IDENTIFY",
	}

  if ScrollTypes["%1"] then
    ColourNote(TriggerStyleRuns[1].textcolour, TriggerStyleRuns[1].backcolour,
     "%0 " .. ScrollTypes["%1"])

  else
    ColourNote(TriggerStyleRuns[1].textcolour, TriggerStyleRuns[1].backcolour,
     "%0")
  end
</send>

  </trigger>
</triggers>


The placement is great but none of the original line colors come through. That would be excellent.

--

working way to hard to play
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #3 on Mon 05 Jul 2010 06:55 PM (UTC)

Amended on Mon 05 Jul 2010 06:56 PM (UTC) by Twisol

Message
Give this a try. Written on faith, just like WillFa's.


<triggers>
  <trigger
   enabled="y"
   match="^(?: \([\s\d]+\))?\s+([\w\s-]+) scroll \(new\)$"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >

<send>ScrollTypes = {
	["a glossy lime"] = "ARMOR",
	["an ivory-yellow papyrus"] = "BLINDNESS",
	["a charcoal lambskin"] = "REVEAL",
	["a copper-colored"] = "IDENTIFY",
	}
  for _,v in ipairs(TriggerStyleRuns) do
    ColourTell(v.textcolour, v.backcolour, v.text)
  end
  
  if ScrollTypes["%1"] then
    local last = TriggerStyleRuns[#TriggerStyleRuns]
    ColourNote(last.textcolour, last.backcolour, " " .. ScrollTypes["%1"])
  end
</send>

  </trigger>
</triggers>

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Deacla   USA  (42 posts)  Bio
Date Reply #4 on Mon 05 Jul 2010 07:04 PM (UTC)
Message
Same exact result. Trigger works and appends the spell name, but it's stuck in the normal world note color. none of the original comes through.

--

working way to hard to play
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #5 on Mon 05 Jul 2010 07:11 PM (UTC)

Amended on Mon 05 Jul 2010 07:17 PM (UTC) by Twisol

Message
That's very odd. As you can probably tell, we're actually accessing the style runs the original line had.

Only thing that comes to mind is, make sure you delete old versions of the trigger before you import the new one.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Deacla   USA  (42 posts)  Bio
Date Reply #6 on Mon 05 Jul 2010 07:17 PM (UTC)
Message
well i placed the trigger code in it's own little plugin and deleted all the previous simple triggers i had. i even restarted MUSH. Am i supposed to have the code somewhere else?

I can see what's supposed to be happening and looked up the commands for clarification. It's just not working as advertised. I'm running version 4.43 if that matters.

--

working way to hard to play
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #7 on Mon 05 Jul 2010 07:19 PM (UTC)
Message
Deacla said:
well i placed the trigger code in it's own little plugin and deleted all the previous simple triggers i had. i even restarted MUSH. Am i supposed to have the code somewhere else?

That should probably work...

Deacla said:
I can see what's supposed to be happening and looked up the commands for clarification. It's just not working as advertised. I'm running version 4.43 if that matters.

I don't remember any style-run changes from 4.43 on, but it's not out of the question...

One moment, I'm going to test this trigger out.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #8 on Mon 05 Jul 2010 07:41 PM (UTC)

Amended on Mon 05 Jul 2010 07:48 PM (UTC) by Twisol

Message
Looking into it, the trigger wasn't even matching. But I just realized a new problem. It'll be a bit.. complex to figure out how to "splice" some content into a line without throwing off the line styles. If we didn't have to worry about the line styles, we could have two more captures in the trigger - one for stuff before the insertion point, and one for stuff after it - and just Note it out. But we're relying on the styles list to re-print the line, and there's no shared context between it and the trigger matches.

If you're okay with the line being one solid color, that's very easy.


Also, I rewrote the match pattern. Seems to work fine now.

<triggers>
  <trigger
   enabled="y"
   match="^((?:\(\s*\d+\))?\s*(.*?) scroll) (\(new\))$"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  <send>ScrollTypes = {
  ["a glossy lime"] = "ARMOR",
  ["an ivory-yellow papyrus"] = "BLINDNESS",
  ["a charcoal lambskin"] = "REVEAL",
  ["a copper-colored"] = "IDENTIFY",
}

if ScrollTypes["%2"] then
  ColourNote("white", "black", "%1 " .. ScrollTypes["%2"] .. " %3")
else
  for _,v in ipairs(TriggerStyleRuns) do
    ColourTell(RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), v.text)
  end
  Note() -- finish the line
end</send>
  </trigger>
</triggers>


EDIT: Fixed an issue that was, in retrospect, a bit obvious: the textcolour and backcolor items are numbers in RGB format, but ColourTell only accepts color names. Fixed above.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Deacla   USA  (42 posts)  Bio
Date Reply #9 on Mon 05 Jul 2010 08:09 PM (UTC)
Message
made a couple changes thinking that it may make it easier with this format to keep the colors also changed the textcolour to match my main text colour in case an actual matching can't be worked out..

<triggers>
  <trigger
   enabled="y"
   match="^((?:\(\s*\d+\))?\s*(.*?) scroll) (\(new\))$"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  <send>ScrollTypes = {
  ["a glossy lime"] = "ARMOR",
  ["an ivory-yellow papyrus"] = "BLINDNESS",
  ["a charcoal lambskin"] = "REVEAL",
  ["a copper-colored"] = "IDENTIFY",
}

if ScrollTypes["%2"] then
  ColourNote("silver", "black", "%1 " .. " %3    " .. ScrollTypes["%2"])
else
  for _,v in ipairs(TriggerStyleRuns) do
    ColourTell(RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), v.text)
  end
  Note() -- finish the line
end</send>
  </trigger>
</triggers>

If it would make it easier to keep the styles by appending the spellname all the way to the end as in this example:

A gnomish miner's bag contains:
(  7) a copper-colored scroll  (new)    IDENTIFY
( 20) a blackjack voucher notated with a little '500' (new)
     a glossy lime scroll  (new)    ARMOR
(  2) an unusual swamp flower
     a nightshade mushroom
     an ivory-yellow papyrus scroll  (new)    BLINDNESS
     a charcoal lambskin scroll  (new)    REVEAL

--

working way to hard to play
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #10 on Mon 05 Jul 2010 08:37 PM (UTC)
Message
Deacla said:
If it would make it easier to keep the styles by appending the spellname all the way to the end as in this example:

A gnomish miner's bag contains:
(  7) a copper-colored scroll  (new)    IDENTIFY
( 20) a blackjack voucher notated with a little '500' (new)
     a glossy lime scroll  (new)    ARMOR
(  2) an unusual swamp flower
     a nightshade mushroom
     an ivory-yellow papyrus scroll  (new)    BLINDNESS
     a charcoal lambskin scroll  (new)    REVEAL


Yeah, that makes it much easier:

<triggers>
  <trigger
   enabled="y"
   match="^((?:\(\s*\d+\))?\s*(.*?)\s*scroll)\s*(\(new\))$"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  <send>ScrollTypes = {
  ["a glossy lime"] = "ARMOR",
  ["an ivory-yellow papyrus"] = "BLINDNESS",
  ["a charcoal lambskin"] = "REVEAL",
  ["a copper-colored"] = "IDENTIFY",
}

for _,v in ipairs(TriggerStyleRuns) do
  ColourTell(RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), v.text)
end

if ScrollTypes["%2"] then
  ColourTell("silver", "black", "\t" .. ScrollTypes["%2"])
end

Note() -- finish the line</send>
  </trigger>
</triggers>

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Deacla   USA  (42 posts)  Bio
Date Reply #11 on Mon 05 Jul 2010 08:45 PM (UTC)
Message
That's it right there Twisol. thx very much.

Also i will post a copy of the full code when i get all the scrolls programmed in.

--

working way to hard to play
Top

Posted by Deacla   USA  (42 posts)  Bio
Date Reply #12 on Tue 06 Jul 2010 12:38 AM (UTC)
Message
As promised, here is the Materia Magica Scroll to Spell Translator for Mushclient.

https://docs.google.com/leaf?id=0B9VJQA8iYaroYjY2MzY0NTYtNTFkOC00YWRlLWIwYjQtMWUwZWE3ODFkZjA5&sort=name&layout=list&num=50

--

working way to hard to play
Top

Posted by Deacla   USA  (42 posts)  Bio
Date Reply #13 on Wed 07 Jul 2010 02:47 AM (UTC)

Amended on Wed 07 Jul 2010 02:52 AM (UTC) by Deacla

Message
One last thing. I'm having trouble turning this string into regexp so that it also fires the scroll trigger.

AUCTION: Deacla has put a luminescent mother-of-pearl scroll up for auction. Minimum bid is 100 gp.

I've tried myself and can get it to install but it never fires. any help would be great.

Also how can i put both strings into one trigger so it says either fire on this or this.... or this potentially?

edit: this is what i have so far to show you the variable aspects of the string.

^AUCTION\:\s*(.*?)\s*has put(\s*(.*?)\s*scroll) up for auction\. Minimum bid is (.+) gp\.$

--

working way to hard to play
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #14 on Wed 07 Jul 2010 03:38 AM (UTC)
Message
That regexp fired for me on your test string.

If you want to fire both, make sure they both have "keep evaluating" set.

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


64,904 views.

This is page 1, subject is 2 pages long: 1 2  [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.