How do I create a Lua function trigger to play a sound?

Post Reply
kuei
Posts: 4
Joined: Sat Jun 27, 2009 3:05 am

How do I create a Lua function trigger to play a sound?

Post by kuei »

My failed attempt was to create a trigger named bottle_pop_1() to play the sound file bottle_pop_1.wav

Code: Select all

<Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="yes" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
            <name>bottle_pop_1()</name>
            <script>echo("Trigger516()")
</script>
            <triggerType>0</triggerType>
            <conditonLineDelta>0</conditonLineDelta>
            <mStayOpen>0</mStayOpen>
            <mCommand></mCommand>
            <mFgColor>#ff0000</mFgColor>
            <mBgColor>#ffff00</mBgColor>
            <mSoundFile>C:/Users/kuei/.config/mudlet/Sounds/bottle_pop_1.wav</mSoundFile>
            <colorTriggerFgColor>#000000</colorTriggerFgColor>
            <colorTriggerBgColor>#000000</colorTriggerBgColor>
            <regexCodeList>
                <string>bottle_pop_1()</string>
            </regexCodeList>
            <regexCodePropertyList>
                <integer>4</integer>
            </regexCodePropertyList>
        </Trigger>
When calling bottle_pop_1() the debugger said the function did not exist. So I used a work around.

I called it using Trigger516() and it successfully echoed back Trigger516(), but it did not play the sound.
The debugger said it successfully ran Trigger516(). I have had triggers play sounds before, but never
one using a Lua function so I suspect the Lua Function may be the problem.

So how do I get bottle_pop_1() to fire or should I just make it a regular trigger without the Lua
function, call it as Trigger###() to play the sound file?

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: How do I create a Lua function trigger to play a sound?

Post by Heiko »

I'll add a playSoundFile( file ) Lua function to the next version. If you are on Linux you can use the Lua os. library function as a workaround. Have a look at the Howto section in the forum

Post Reply