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.
 Entire forum ➜ MUSHclient ➜ Lua ➜ Speaking warnings

Speaking warnings

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


Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Sat 27 May 2006 10:43 PM (UTC)
Message
Some ideas presented in another thread show how to speak things using the SAPI COM object:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=6586

As that is a VBscript thread, in the Lua section I will show how you could make a trigger that speaks a warning when your health is low:


<triggers>
  <trigger
   enabled="y"
   match="^\&lt;(\d+)\/(\d+)hp (\d+)\/(\d+)m (\d+)\/(\d+)mv (\d+)\/(\d+)xp\&gt;"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>if not talk then
  assert (loadlib ("luacom.dll","luaopen_luacom")) ()
  talk = assert (luacom.CreateObject ("SAPI.SpVoice"), "cannot open SAPI")
end -- no talk yet

if %1 &lt; 100 and oldhealth ~= %1 then
  talk:Speak ("Health is down to %1!", 1)
  oldhealth = %1  -- remember health level
end -- low health</send>
  </trigger>
</triggers>



For this to work you need luacom.dll in the same directory as MUSHclient.exe, which I found at:


http://luaforge.net/frs/download.php/922/luacom-1.3-luabinaries-bin.zip


This uses a test on the "talk" variable to save re-instantiating the COM object every time the trigger fires. It also does asynchronous speaking (thanks, Ked!) so the client does not pause while it speaks.

It also remembers the last health level to save repeating the same value.

- Nick Gammon

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

Posted by Nexes   (65 posts)  Bio
Date Reply #1 on Wed 12 Jul 2006 11:57 PM (UTC)
Message
For some reason, when I try to use this it DOES pause the client. Triggers and stuff may or may not still be processed but I can't see it, because nothing is updated on the GUI while it speaks.

Im not sure if that's full pausing of the client or not but it's still annoying. Wish it didn't do that. :(
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #2 on Thu 13 Jul 2006 02:42 AM (UTC)
Message
Seems to be working OK for me, the GUI keeps updating.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 13 Jul 2006 02:47 AM (UTC)
Message
I'm not sure if this is the right file, but I have:


C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll


Its version is 5.1.4111.0.

- Nick Gammon

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

Posted by Nexes   (65 posts)  Bio
Date Reply #4 on Thu 13 Jul 2006 05:06 AM (UTC)
Message
Sorry. Im an idiot and I didn't read the thread you linked.

I wasn't passing 1 to the speak object. *sigh*
Top

Posted by Fletchling   Australia  (54 posts)  Bio
Date Reply #5 on Sat 06 Jan 2007 01:36 AM (UTC)
Message
Nick,

Using 3.80, I get the error below for this trigger;

[string "Trigger: "]:1: The specified procedure could not be found.
stack traceback:
[C]: in function 'assert'
[string "Trigger: "]:1: in main chunk

I've changed loadlib to package.loadlib, and have luacom.dll 5.1 in the mushclient directory.

Any clues you could offer to point me to the next step?

Thanks.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #6 on Sat 06 Jan 2007 03:50 AM (UTC)
Message
After a bit of research I found that the entry point had been renamed. The line that loads the SAPI interface now needs to read:


assert (package.loadlib ("luacom.dll","luacom_open")) ()


- Nick Gammon

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

Posted by Fletchling   Australia  (54 posts)  Bio
Date Reply #7 on Sat 06 Jan 2007 06:35 AM (UTC)
Message
that change worked for me, thanks Nick. I'd been using some *.wav files to alert me to special events, but I really don't like the soundof my voice, so sam is much better.

Thanks!
Top

Posted by Beale   (35 posts)  Bio
Date Reply #8 on Sun 07 Jan 2007 11:51 AM (UTC)
Message
I thought I'd try this, but every time this line is executed:
 assert (package.loadlib ("luacom.dll","luacom_open")) ()

MUSHClient 3.84 crashes with one of Windows' "Do you want to send an error report?" messages. Flicking through the report dump, Lua 5.0.2 (which is odd - I thought MUSHClient was using 5.1 - and removing the lua50.dll from the MUSHClient directory makes the line throw up an error "The specified module could not be found.") seems to be giving an error like:
control structure too long.
function or expression too complex..
constant table overflow.
code size overflow.
value for 'lua_getinfo' is not a function..

Followed by a whole bunch of other errors, and finally:
loadlib.init....
system error %d



Any insight?
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #9 on Sun 07 Jan 2007 06:40 PM (UTC)
Message
It sounds very much like you are using a version of luacom.dll which is designed for Lua 5.0, hence the fact that it is loading the lua50.dll file.

See:

http://www.gammon.com.au/forum/?id=7341

In there are links for downloads for luacom.dll which is designed for Lua 5.1.

- Nick Gammon

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

Posted by Beale   (35 posts)  Bio
Date Reply #10 on Sun 07 Jan 2007 09:36 PM (UTC)
Message
Ah, thanks. I didn't spot that when I was flicking over the warning.
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.


38,023 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.