Suggestions for triggers

Posted by Nick Gammon on Sun 04 Mar 2001 04:17 PM — 11 posts, 44,168 views.

Australia Forum Administrator #0
Triggers can greatly simplify playing a MUD by reacting automatically to incoming text.

You can use them to :

* Colour text (eg. chat channels)
* Highlight words (eg. your name)
* Gag annoying players
* Play sounds
* Automatically send something to the MUD
* ... and more ...

For greater detail, see the page:

http://www.gammon.com.au/mushclient/funwithtriggers.htm



Examples

Respond to events

Match on: You have been idle, and are pulled into a void.
Send: look

Match on: You are thirsty.
Send: drink water

Match on: You are hungry.
Send: eat food

Match on: You collapse, totally out of breath!
Send: stand

Match on: You fall down.
Send: stand

Gag trivial messages

Match on: * dodges
Omit from output: checked

Match on: * misses
Omit from output: checked

Match on: You dodge
Omit from output: checked

Match on: You parry
Omit from output: checked

#1
so.. i don't get it... (taps her blonde ponytail)
what's the syntax you use for highlighting strings?
I haven't been able to get it to work yet...
Amended on Fri 06 Apr 2001 01:34 AM by Gialynn
Australia Forum Administrator #2
OK, let's say you want to hilight the word "Gialynn" whenever it appears.

1. Go to Configuration -> Appearance -> Triggers.

2. Add a new trigger

3. Enter the following fields:

Trigger: Gialynn
Regular Expression: checked
Change colour and style to: Custom1

Leave the rest alone.

4. Click OK to add the trigger.

5. Click OK to dismiss the configuration dialog.

Now try sending a message with that name in it, and it should be highlighted. If you don't like the colour, go to Configuration -> Appearance -> Custom Colour, click on the swatch for Custom1, and change the colour (text colour, and background colour are separate swatches).

Amended on Fri 06 Apr 2001 01:49 AM by Nick Gammon
#3
Is there a way to change sequnce number in trigger by script?
Or turn off/on echoing commands by script?

____
Robert Mituniewicz
#4
ok... got the trigger setup for single line things down....

Now...

the MUD I play has a 2 type ahead limit... I want to do a
few three and 4 line macros and triggers... is there some
kind of 'pause' I can enter in that will make the macro and/or
trigger wait a second or two before sending the next command?

also.. the button at the bottom (the 'save' button) should
say 'SEND', not save, since when pressing it, the message is
SENT to you, not saved to my 'puter...

i know..i'm picky...but i'm a blonde...and a Yank...
Amended on Mon 09 Apr 2001 10:21 PM by Gialynn
Australia Forum Administrator #5
Quote:

Is there a way to change sequnce number in trigger by script?
Or turn off/on echoing commands by script?


At this stage I think that triggers are added with the default sequence number of 100. All I can suggest is to make the other ones above/below the ones added by the trigger.

As for turning on/off echoing commands - not at present, however I have added that as suggestion #393.

Australia Forum Administrator #6
Quote:

the MUD I play has a 2 type ahead limit... I want to do a
few three and 4 line macros and triggers... is there some
kind of 'pause' I can enter in that will make the macro and/or trigger wait a second or two before sending the next command?


To do this you could make your trigger "Send to world (speedwalk delay)" and make the speedwalk delay the number of seconds you want.

There isn't a similar thing for macros, however you could make an alias which matches on whatever you want to send, and the alias can call a script, and in the script you can make it "Queue" the command (which sends it at the speedwalk delay). However I have added the idea of making that an option on a macro (delayed sending) as suggestion #394.

Quote:

also.. the button at the bottom (the 'save' button) should
say 'SEND', not save, since when pressing it, the message is SENT to you, not saved to my 'puter...


Ah, the button at the bottom of what?
Amended on Mon 09 Apr 2001 10:24 PM by Nick Gammon
#7
I think you should post on this site how to set up a tick timer and trigger. A straight timer won't work, cause its slightly randomn so it needs to by synced occasionally. If someone could do this it would help out us newbies greatly.
Australia Forum Administrator #8
Can you post an example of what you see when the tick timer needs to be synced? Just copy and paste from the output window in MUSHclient for accuracy.

Also mention the rough period for the tick, and I'll try to do the examples you mention.
#9
A tick is between 58 and 62 seconds, its randomn by about 2 seconds.
Things that could sync it are:
Darkness marks the end of another day.
It starts to rain.
Thunder announces the beginning of the storm.
With your studies complete, you close your spellbook


If you could explain this in detail that would be greatly appreciated.
Australia Forum Administrator #10
OK, this sounds simple enough ...

Make the timer

First, make a timer by using the timer configuration screen ...

File menu -> World Properties -> General -> Timers

1. Click on "Add"
2. On the first line (Every interval) type "60" into the seconds box
3. It depends a bit on what you want to do with the ticks, but for now enter "think tick", or something like that, into the "send" box.
4. Enter "tick_timer" into the "label" box. This gives the timer a name.

Synchronise the timer

Now you need a trigger that will synchronise the timer to allow for its randomness.

Make a trigger by using the trigger configuration screen ...

File menu -> World Properties -> Appearance -> Triggers

1. Click on "Add".
2. Fill in the following fields:


Trigger: ^(Darkness marks the end of another day.|It starts to rain.|Thunder announces the beginning of the storm.|With your studies complete, you close your spellbook.)$

Send: Tick synchronised.

Send to: Output

Regular Expression: checked

Label: tick_trigger

Script: OnTickTrigger



What this will do is use a regular expression to check on one of your various messages (the "|" is an "or" symbol, so it means "this" or "that").

The message must be spelt exactly correctly or it won't match. Preferably copy and paste a genuine one. Even a missing period at the end will stop it matching.

The trigger will echo "Tick synchronised." to the output window (so you can see that the trigger has matched). You can omit that if it is annoying.

The trigger also calls a script subroutine "OnTickTrigger". You must put this into your script file. Here is an example in VBscript and JScript:

VBscript


sub OnTickTrigger(strTriggerName, strTriggerLine, arrWildCards)
world.ResetTimer "tick_timer"
end sub



Jscript


function OnTickTrigger(strTriggerName, strTriggerLine, wildcardsVB)
{
world.ResetTimer("tick_timer");
}



You could add these to the end of the exampscript files supplied with MUSHclient, or just paste them into a separate file (using the notepad).

Make sure scripting is enabled, the appropriate language is selected, and that this file is selected as the script file.

The net effect will be that when the trigger fires, the timer will "reset" which means it will start counting from zero again. This will wipe out the cumulative effect of the random seconds.

Have fun.