Page 1 of 1

Help me with an easy script

Posted: Wed Jan 23, 2013 6:39 am
by Lemuel
I use MushClient. I know how to use timers, aliases, and triggers. Often I employ * to make one alias/trigger cover a lot of situations.

That is the extent of my knowledge of MushClient. I want to build a script to help my character respond to 'hands full' messages efficiently. In my case, I'll be using a whip for a few hours, then I'll switch to a flintlock for a few hours, then a stiletto.

I would like someone to show me how to make a script I can put in my triggers to cover all prompts such as
You can't do that with your hands full.

You need an empty hand or to be holding an open container in your right hand in order to buy something.

You'll need to be holding a bandage or have one in an open worn container.

Your hands are full!
and so on, so that in all these situations, it will respond with 'wear whip' ; and I will be easily able to change the response to all these in one fell swoop to 'put flintlock in holster'.

Can someone show me how to do this? This will help me to reduce, as I have been doing, a blanket trigger that always sends multiple commands (wear whip, put flintlock in holster, put rapier in scabbard, put dagger in bandolier, etc.) as a response to these situations which I guess is not healthy for the server.

Posted: Wed Jan 23, 2013 7:34 am
by Eldwin
First, create several new triggers for items in your hands.

When you create the triggers, check the Regular expression box, uncheck the Enabled box, set Send To to "Script", and assign them to a group such as EmptyHands.

Make the Trigger text like the following:
^You are holding (.*?) whip in your right hand and (.*?)\.$
^You are holding (.*?) flintlock in your right hand and (.*?)\.$
^You are holding (.*?) stiletto in your right hand and (.*?)\.$

Quick lesson on Regular Expressions...
^ matches the beginning of the line, this is telling MUSHclient to only match this trigger if it is on a new line, so if someone copies and pastes your trigger text, it won't fire.
(.*?) matches any number of any characters. This tells mushclient that there can be anything between "holding" and "whip", such as "a leather" or "A really cool leather" or whatever. Also, your left hand can be anything as well.
\ is an escape character. Since the period (.) is used in RegEx, if you want to actually match a period in the trigger text you need to escape it first with \.
$ matches the end of the line

For each of these three triggers, make sure Enabled is unchecked, Regular Expression (on the right) is checked, Send To (below the send box) is set to Script.

Enter the following in the send box for your whip trigger:
Send("wear whip")
EnableTriggerGroup("EmptyHands",false)

Do the similar for your stiletto and flintlock triggers, but change the Send("whatever") line.

Create new triggers for the standards "hands full" messages. These do NOT have to be Regular Expression. But still set them to Send To Script (do NOT put them in the EmptyHands group

All those triggers should have in them is:

EnableTriggerGroup("EmptyHands",true)
Send("hands")

This will turn on the triggers in the EmptyHands group and look at the items in your hands. It will then match the appropriate trigger, put away an item, then disable the EmptyHands triggers again.