Use a timer in a custom script

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
DranDane
Posts: 18
Joined: Mon Dec 08, 2008 2:23 pm

Use a timer in a custom script

Post by DranDane » Fri Feb 20, 2009 4:50 pm

Hello,

It's the first time I code in python. Could you just explain me how I can use a timer (from the timer module) in custom script. I would like to be able to retrieve the timer counter to say a specific message.

Something like

Code: Select all

Speech.TextToSpeech(u'Microsoft Sam', 0, u'The timer already did {var} loops', 0, 100)
Thank you,

User avatar
topix
Experienced User
Posts: 441
Joined: Sat May 05, 2007 3:43 pm
Location: Germany
Contact:

Re: Use a timer in a custom script

Post by topix » Sun Feb 22, 2009 7:26 pm

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="851">
    <Folder Name="Timer_Test" Expanded="True">
        <Macro Name="Timer Start" Expanded="True">
            <Action>
                Timer.TimerAction(u'test', 0, 10, 3.0, u'testtimer', False, False, 0, u'00:00:00')
            </Action>
        </Macro>
        <Macro Name="Python Script" Expanded="True">
            <Event Name="Timer.testtimer" />
            <Action>
                EventGhost.PythonScript(u'print "This is the %d. loop." % (eg.event.payload[0] + 1)')
            </Action>
        </Macro>
    </Folder>
</EventGhost>

DranDane
Posts: 18
Joined: Mon Dec 08, 2008 2:23 pm

Re: Use a timer in a custom script

Post by DranDane » Mon Feb 23, 2009 9:28 am

Thank you very much Topix.

I did a search with the word "payload" and I found this page http://www.eventghost.org/wiki/Scripting.

Post Reply