It helps to see actual MUD output so we can see exactly what the triggers will be, so I have to guess a bit. This single trigger should do it:
<triggers>
<trigger
enabled="y"
match="* gives you a * type scratch card"
send_to="12"
sequence="100"
>
<send>
do local t = coroutine.create (function (t)
-- scratch the card
Send "scratch %2 card"
local line, wildcards = waitforregexp (t,
"^(Your card wins! You get (?P<gold>.+) gold.|Your card loses\\.)$")
-- check for win or loss
if string.find (line, "wins") then
local gold = wildcards.gold -- amount won
Send ("say You won " .. gold .. " gold!")
Send ("give " .. gold .. " to %1" )
else
Send ("say Bad luck, your card lost.")
end -- if
end) assert (coroutine.resume (t, t)) end
</send>
</trigger>
</triggers>
For a discussion of how it works, see:
http://www.gammon.com.au/forum/?id=4957
You need the "wait" functions described on that page to make it work. They ship in the exampscript.lua file that comes with MUSHclient, so just make that your script file (or more safely, make a copy of it and make the copy your script file).
The above stuff gets copied and pasted into the trigger configuration list, see this post for how to do that:
http://www.gammon.com.au/forum/?id=4777
How it works ...
- The trigger itself matches on the thing that starts the sequence off, I guessed it would be like this:
John gives you a frizzle type scratch card
You need to amend the trigger to get it to match exactly, or nothing will happen.
- The trigger starts up a coroutine (the first line in the trigger - the reason for that is explained in the post I mentioned. Effectively a coroutine can pause and wait for further input.
- It then sends the scratch command:
scratch frizzle card
- It waits on a regular expression which matches either the win or lose message from the MUD.
In this case I am expecting either:
Your card wins! You get 55 gold.
or
Your card loses.
Again you need to modify that regexp to match what you really get.
It then checks which regular expression matched by checking for the word "wins" in the matching line. If it was a win, it sends a message to the player, and a "give" command.
If it is a loss, it simply send a message to the player.
All of these need to be tweaked to match what the exact message format should be.
That's it basically. The coroutine idea simplifies somewhat a multi-line response like this.