Getting Trigger text

Posted by Korishan on Fri 14 Feb 2003 03:52 AM — 7 posts, 27,921 views.

USA #0
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.
Russia #1
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?
USA #2
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
Russia #3
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.
Australia Forum Administrator #4
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\] -.*)$
USA #5
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.
Australia Forum Administrator #6
Ah, OK, you can update an existing trigger's match text, see SetTriggerOption.