require "wait"

Posted by Ammanas on Thu 29 Oct 2009 05:41 PM — 7 posts, 29,636 views.

#0
I have been working on something for a couple of days now, and can't seem to get it to work. If anyone would be able to help, I would appreciate it greatly.

http://pastebin.com/m7cb6f8c6
USA #1
The wait module is good for inserting pauses into your script so you can evaluate the return.

i.e. search table
wait for response
if found candle then dothis
else dothat
end

You are doing just a simple one time delay. DoAfter(2, "say lots of stuff") is probably all you need in this case.
#2
I would have used DoAfter, but it doesn't seem to work either.
Australia Forum Administrator #3
I would use DoAfter for the situations you showed - that is shorter and simpler to look at. I would rather work out why DoAfter doesn't work than throw that away and try a different approach.

Check the triggers actually fire - when you edit each trigger it shows in the bottom RH corner the count of times it fired. If it is zero, then whatever the code does won't matter.

As an example, one of your match lines is:


match="You say in a faint, raspy voice, "Greetings Mhaldorian, your attendance is appreciated. "


Does the line really end with a trailing space? Does it really start with "You say" or is there a prompt there too? Please post some example MUD output (copy and paste) so we can see exactly what you are trying to match on.

One tiny thing wrong in a trigger like that (eg. there isn't a trailing space) and it won't match.
#4
Yeah it shows them as not firing. This is the whole output:

Quote:

say Greetings Mhaldorians, your attendance is most appreciated. Before we begin, let us bow our heads in an opening prayer.
You say in a faint, raspy voice, "Greetings Mhaldorians, your attendance is
most appreciated. Before we begin, let us bow our heads in an opening prayer."
2830h, 2205m, 13050e, 8925w ex-


I tried the DoAfter first. When that wouldn't work, I tried require "wait".

This is what I just changed it to, still not firing:

Quote:

<triggers>
<trigger
enabled="y"
ignore_case="y"
match="You say in a faint, raspy voice, &quot;Greetings Mhaldorians, your attendance is most appreciated. Before we begin, let us bow our heads in an opening prayer.&quot;"
regexp="y"
send_to="12"
sequence="2050"
>
<send>DoAfter(2, "emote bows his head and crosses his hands calmly before him.")</send>
</trigger>
</triggers>


Some of them are really long, so I didn't know if it was able to leave most of it off and just work to fire on the first few words, or if everything had to be included.
Amended on Fri 30 Oct 2009 05:56 PM by Ammanas
Australia Forum Administrator #5
I'm seeing two lines here:


You say in a faint, raspy voice, "Greetings Mhaldorians, your attendance is 
most appreciated. Before we begin, let us bow our heads in an opening prayer."


Unless you use multi-line triggers, a trigger matches a single line.

You can probably get away with matching the partial line anyway. You already had regular expressions checked (which was a bit dubious because you should really put a backslash in front of things like periods). However this worked for me on your test case:


<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   match="^You say in a faint, raspy voice, &quot;Greetings Mhaldorians, your attendance "
   regexp="y"
   send_to="12"
   sequence="2050"
  >
  <send>DoAfter(2, "emote bows his head and crosses his hands calmly before him.")</send>
  </trigger>
</triggers>


The "^" means "match from the start of the line" and then you can just type in enough to make the trigger unique.
USA #6
Since this looks like Achaea you're playing ('Mhaldorians' and such), what I would do is CONFIGURE SCREENWIDTH 0 to turn off wrapping, then in MUSHclient go to Game -> Configure -> Output and check the box next to "Wrap output at column number" near the bottom-right. Set the numeric field to 80 (or whatever you prefer your screenwidth to be). And uncheck "Indent paragraphs" on the right.

That should do nothing visibly to the output, but it basically shifts the line wrapping over from the server to the client. Long SAYs like the above, normally sent as two separate lines with a SCREENWIDTH of 80, would be sent as one single line. It really simplifies triggers.