Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Pausing actions on timers

Pausing actions on timers

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Ammanas   (8 posts)  Bio
Date Fri 19 Feb 2010 11:18 PM (UTC)
Message
I have a string of emotes and things to be said in one trigger that matches on one line. This is done with DoAfter, and I was wondering if there were a way to pause/unpause the string, and terminate(stop it completely). I have an alias set up to disable and enable my triggers via ET/DT, yet when disabled, the trigger still goes through. I'm guessing it does this due to the fact that using DoAfter, it has to send to the script rather than the world. I am hoping I do not have put each little part into its own alias, it's quite lengthy. Any and all help is greatly appreciated, thank you in advance.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 20 Feb 2010 12:38 AM (UTC)

Amended on Sat 20 Feb 2010 12:44 AM (UTC) by Nick Gammon

Message
Yes that is easy enough. Instead of DoAfter you want to use the "wait" module in Lua. An example is below:


<triggers>
  <trigger
   enabled="y"
   match="smiles at you"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

require "wait"
require "getlines"

-- whatever you want to say, put here between the square brackets ...

text = [=[
Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
sed do eiusmod tempor incididunt ut labore et dolore magna 
aliqua. Ut enim ad minim veniam, quis nostrud exercitation 
ullamco laboris nisi ut aliquip ex ea commodo consequat. 
Duis aute irure dolor in reprehenderit in voluptate velit 
esse cillum dolore eu fugiat nulla pariatur. 
Excepteur sint occaecat cupidatat non proident, sunt in 
culpa qui officia deserunt mollit anim id est laborum.]=]

wait.make (function ()

-- clear stop and pause flags
pause_message = false
stop_message = false

for line in getlines (text) do

  Send ("say " .. line)  -- send next line

  repeat
    wait.time (3)  -- wait 3 seconds
  until not pause_message

  if stop_message then
    Note "speech halted"
    break
  end -- if stop
end -- for each line

Note "Speech finished!"

end)
</send>
  </trigger>
</triggers>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


Change the trigger match to suit, and the message itself of course. You can change "say " to "emote " or whatever you want.

In my example it waits 3 seconds between lines, you can change that to whatever you want.

Now to pause the speech, make an alias that simply sets the variable pause_message, and to halt it make an alias that sets the variable halt_message, like this:


<aliases>
  <alias
   match="pause speech"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

pause_message = true
Note "Speech paused"

</send>
  </alias>

  <alias
   match="resume speech"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

pause_message = false
Note "Speech resumed"

</send>
  </alias>

  <alias
   match="stop speech"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

stop_message = true
Note "Speech stop initiated"

</send>
  </alias>
</aliases>


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ammanas   (8 posts)  Bio
Date Reply #2 on Sat 20 Feb 2010 01:15 AM (UTC)

Amended on Sat 20 Feb 2010 02:17 AM (UTC) by Ammanas

Message
I see. On the Match line, in this form will it match multiple lines, or just to the point where the first line wraps? Thank you very much for showing me this.

Edit:

I got this error after finishing and trying to paste the triggers into my world:


Line   80: Attribute name 'Mhaldorians' not followed by '=' (problem in this file)



      <trigger
   enabled="y"
   match="You say in a faint, raspy voice, "Mhaldorians, we are gathered here today to give  "
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

require "wait"
require "getlines"

text = [[
slowly bows his head and closes his eyes.]]

wait.make (function ()

-- clear stop and pause flags
pause_message = false
stop_message = false

for line in getlines (text) do

  Send ("em " .. line)  -- send next line

  repeat
    wait.time (25)  -- wait 25 seconds
  until not pause_message

  if stop_message then
    Note "speech halted"
    break
  end -- if stop
end -- for

end)
</send>
  </trigger>


Underlined is Line 80
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 20 Feb 2010 02:13 AM (UTC)
Message
You have a quote within a quote there.

The simplest thing is to paste in my original, unchanged, and then edit it in the client GUI interface.

Anyway, why do you want to match something *you* are saying? Can't you just hit an alias instead, when you want to say it?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Sat 20 Feb 2010 02:15 AM (UTC)
Message
Ammanas said:

it's quite lengthy.


The example you posted wasn't quite lengthy. It was just:


slowly bows his head and closes his eyes.


You know what I posted will do the whole speech, you don't have to do it one line at a time.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ammanas   (8 posts)  Bio
Date Reply #5 on Sat 20 Feb 2010 02:19 AM (UTC)
Message
When I said it was quite lengthy, I meant all of it together. That was just one part of it I was trying to match off of. If it were a couple of emotes, I would use aliases, but this is something lengthy that will go over a few minutes. This is it in full:

http://pastebin.com/f19d88913
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #6 on Sat 20 Feb 2010 02:31 AM (UTC)

Amended on Sat 20 Feb 2010 02:33 AM (UTC) by Nick Gammon

Message
I don't think you quite got what I was trying to explain. I didn't mean you would use that trigger 50 times. I meant a single trigger or alias would do the whole speech. Just one.


I didn't intend you to break it up into lines as you seem to have done, you have just replaced one problem with another one.

Just try this, copy and paste below without changing it in any way:


<aliases>
  <alias
   match="dospeech"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

require "wait"
require "getlines"

text = [[
Ammanas looks solomnly over the group assembled before him, his
hands before him and stands straight as he clears his throat, patiently observing as all grows quiet.
Mhaldorians, we are gathered here today to give thanks to the Twin Lords for one of the greatest gifts 
They have given us, to praise Their names and teachings. Let us begin with a brief prayer 
He slowly bows his head and closes his eyes.
Lords, thank You for everything You have given us. We find strength and wisdom from the Apocrypha and the Seven Truths. 
Help us continue on this path of trial and tribulations that brings us closer to our ultimate potential, that we may better serve You. Amen.
You say reverently in a faint, raspy voice, "Lord, thank You for everything You have given us.  ]]

wait.make (function ()

pause_message = false
stop_message = false

for line in getlines (text) do
  Send ("em " .. line)
  repeat
    wait.time (4)
  until not pause_message
  if stop_message then
    Note "speech halted"
    break
  end -- if stop
end -- for

end)
</send>
  </alias>
</aliases>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


Then type "dospeech", sit back, and watch what happens. The entire speech is read out, with 4 seconds pause between lines.

You don't need some complicated set of triggers that matches the previous line of the speech, this one alias does it all for you.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ammanas   (8 posts)  Bio
Date Reply #7 on Sat 20 Feb 2010 02:59 AM (UTC)
Message
I see what you did there. The problem lies with the time between some parts have to be longer, or else it will all go to quickly.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #8 on Sat 20 Feb 2010 03:08 AM (UTC)

Amended on Sat 20 Feb 2010 03:11 AM (UTC) by Nick Gammon

Message
Well try this variation. Now I have a check for empty lines:


<aliases>
  <alias
   match="dospeech"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

require "wait"
require "getlines"

text = [[
Ammanas looks solomnly over the group assembled before him, his
hands before him and stands straight as he clears his throat, patiently observing as all grows quiet.

Mhaldorians, we are gathered here today to give thanks to the Twin Lords for one of the greatest gifts 
They have given us, to praise Their names and teachings. Let us begin with a brief prayer 
He slowly bows his head and closes his eyes.

Lords, thank You for everything You have given us. We find strength and wisdom from the Apocrypha and the Seven Truths. 
Help us continue on this path of trial and tribulations that brings us closer to our ultimate potential, that we may better serve You. Amen.

You say reverently in a faint, raspy voice, "Lord, thank You for everything You have given us.
]]

wait.make (function ()

pause_message = false
stop_message = false

for line in getlines (text) do

  if Trim (line) == "" then
    repeat
      wait.time (15)  -- pause on empty line
    until not pause_message
  else
    Send ("em " .. line)
    wait.time (1)
  end -- if

  if stop_message then
    Note "speech halted"
    break
  end -- if stop

end -- for

end)
</send>
  </alias>
</aliases>


Now what it does is send lines only 1 second apart (for part of one sentence) but has a 15 second delay on a blank line. These blank lines would be paragraphs where you want a longer delay.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #9 on Sat 20 Feb 2010 03:09 AM (UTC)

Amended on Sat 20 Feb 2010 03:10 AM (UTC) by Twisol

Message
The first line of 'text' probably shouldn't be broken up into two like that.

Ammanas looks solomnly over the group assembled before him, his hands before him and stands straight as he clears his throat, patiently observing as all grows quiet.


Also, some of those are emotes and others appear to be says.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #10 on Sat 20 Feb 2010 03:13 AM (UTC)
Message
Well the text wasn't perfect. Actually you could simply put "emote" or "say" on the lines instead of in the alias, eg.


say Mhaldorians, we are gathered here today to give thanks to the Twin Lords for one of the greatest gifts 
say They have given us, to praise Their names and teachings. Let us begin with a brief prayer 
emote slowly bows his head and closes his eyes.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ammanas   (8 posts)  Bio
Date Reply #11 on Sat 20 Feb 2010 03:42 AM (UTC)

Amended on Sat 20 Feb 2010 04:55 AM (UTC) by Ammanas

Message
Yeah was wondering about that. I'm fixing to try it out. Thank you, this seems much easier and I've learned a lot so far.

This was a huge success, everything worked perfectly. I sincerely thank you for your assistance in helping me learn how to do this, and patiently working with me.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


37,507 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.