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 ➜ Getting Trigger text

Getting Trigger text

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


Posted by Korishan   USA  (5 posts)  Bio
Date Fri 14 Feb 2003 03:52 AM (UTC)
Message
Hello. I'm working on an infoprompt for the mud I play. It uses the Prompt as a trigger. What I'm wondering is, how can you see the "text" of the trigger? I'm doing this for debugging reasons, mainly.
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #1 on Fri 14 Feb 2003 07:31 AM (UTC)
Message
What do you mean by the "text"? Is that the "text" that the trigger matches on, or the one it sends back to the MUD?
Top

Posted by Korishan   USA  (5 posts)  Bio
Date Reply #2 on Sat 15 Feb 2003 12:37 AM (UTC)
Message
Sorry. Yeah, I'm talkin about the "matching text".

IE. If a trigger matches a prompt of "[%h|%m|%v]" and the player changes thier prompt to "[%h\%H|%m\%M|%v\%V]", and they send the command (which i coded) to change to the new prompt, it would update the trigger matching to the new prompt. So yes, the matching text is what I am referring to.

My appologies for not making that clear to begin with.

TIA
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #3 on Sat 15 Feb 2003 11:37 AM (UTC)
Message
Hmmm, if I understand you correctly then all you need to do is to have 2 triggers, each matching on one of the prompt formats. Then the player could switch between the triggers by using an alias (by disabling one trigger and enabling the other). Here is an example...

Suppose you have the following 2 prompt formats:

Format1
[1273h|1678m|546v] -Some text and a newline.

Format2
[1273h\1850H|1678m\2100M|657v\657V] -Some text and a newline.

Then you'd have to add 2 triggers, conveniently named "prompt_format1" and "prompt_format2", like this:

<trigger
name="prompt_format1"
regexp="y"
enabled="n"
match="^\[(\d+)h\|(\d+)m\|(\d+)v\] -.*$"
sequence=100
></trigger>

<trigger
name="prompt_format2"
regexp="y"
enabled="n"
match="^\[(\d+)h\\(\d+)H\|(\d+)m\\(\d+)M\|(\d+)v\\(\d+)V\] -.*$"
sequence=100
></trigger>

These will pull out the numbers from the prompts for you, if you need them for some sort of processing. The matching expressions (especially the one for 'prompt_format2') look rather gruesome, but thats simply because there are too many 'special' characters to escape.

I normally prefer to keep triggers I don't need at all times disabled, thus both of the above are disabled by default. Obviously one of them would have to be enabled when you connect to the world, but it is up to you to choose which of the two - I can simply show how to enable/disable them from a script using an alias.

Next you'll need an alias:

<alias
name="prompt_choose"
match="prompt *"
enabled="y"
script="SwitchPrompt"
/>

And then you have a script like this:

sub SwitchPrompt (name, output, wildcs)

if (wildcs(1) = "1") then
world.enabletrigger "prompt_format1", True
world.enabletrigger "prompt_format2", False
elseif (wildcs(1) = "2") then
world.enabletrigger "prompt_format2", True
world.enabletrigger "prompt_format1", False
else
world.note "Unknown format of prompt!"
end if
end sub

You can include whatever is needed to switch the prompt itself in the SwitchPrompt sub, so that the prompt proper and the trigger to match on it are manipulated from one place.

The entire thing can actually be put into a plugin it seems, but then again - that depends on what you want to do with the data you get from the prompt.

P.S. If you actually want to have the trigger return the contents of it's 'match' attribute (the "^\[(\d+)h\|(\d+)m\|(\d+)v\] -.*$" in the case of 'prompt_format1' trigger) then I don't think that's even possible. However, if it is then I'd love to know how that is done myself.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Sat 15 Feb 2003 10:11 PM (UTC)
Message
Wildcard 10 is the full matching text. You can test this in a trigger by doing this (set the trigger to "send to output") ...

Send: %%0 = %0

Also, you can nest brackets, so you could do this:

^(\[(\d+)h\|(\d+)m\|(\d+)v\] -.*)$

- Nick Gammon

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

Posted by Korishan   USA  (5 posts)  Bio
Date Reply #5 on Sat 15 Feb 2003 10:21 PM (UTC)
Message
heheh, ok. lemme clarify this one farther :p

The player has a "prompt" of somesort, what ever it is. Then, later on, the player changes to thier prompt to something else. Not flipping between the two prompts.

Just like in the mud, the player can set thier prompt to anything they choice, including "any" option they want. I was wondering if you can update an existing trigger that you define in the <trigger></trigger> part of the script with the new prompt information? Or am I going to have to make a sub routine that creates new triggers everytime the plugin is loaded and not use the <trigger></trigger> part of the script???

Hope this helps even farther in the clarification.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #6 on Sat 15 Feb 2003 10:40 PM (UTC)
Message
Ah, OK, you can update an existing trigger's match text, see SetTriggerOption.

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


27,029 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.