Results 1 to 6 of 6

Thread: Simple Question about Lua

  1. #1
    Join Date
    Oct 2007
    Posts
    3

    Smile Simple Question about Lua

    I am a beginner in Girder-lua, and I need to write a simple script to
    trigger an event periodically, Just want know two things that I found really hard to understand in the Help document.

    1. gir.TriggerEventEx([eventstring], [eventdevice], [keymodifier],[payload] ... )
    where can I find the eventdevice? If I want to trigger a keystroke of "a", what device number should this event belongs to?

    2. [Timer] = gir.CreateTimer([arm], [trigger], [cancel], [recurring],[childstate])
    [Timer]:Arm([timeout])
    If I want to, for example, to active an event once 5 sec, can I say

    while(1)

    --trigger the event
    t = gir.CreateTimer("", "", true, true)
    t:Arm(5000)

    End

    In fact I find this code does not set up a timer as I wanted, but I
    would hardly figure out the problem.
    It will be very helpful if someone could help me with those problems,
    thanks a lot.

  2. #2
    Join Date
    May 2004
    Location
    Dallas, TX
    Posts
    1,125

    Default

    There are a few ways to handle this. Could you describe the action to be taken when your event occurs?
    Rick

    Girder 6.0 - Elk M1 Gold - JRMC 11.1 w/ M-Audio Delta 410 - NetRemote - BlueIris DVR
    Girder 6 Plugins - Elk M1/EZ8, Pushover Connector and more on the way.


    Visit My Showcase

  3. #3
    Join Date
    Nov 2005
    Location
    Redditch, UK
    Posts
    957

    Default

    1. The easiest way to find the eventdevice numbers is to go to Settings>Plugins and when you select the various plugins it shows the deviceid's (I think its the same as the event device but don't quote me on that). On the rest of it I'm not sure as I'm learning Lua too.

    2.
    local eventFunction = function()

    --Trigger your event

    end

    t = gir.CreateTimer("", eventFunction, "", true, true)
    t:Arm(5000)
    Put that into a file called something like "triggerevent.lua" and stick it in the "Girder5\luascript\startup" and it will trigger your event every 5 seconds. That much I do know because I have something similar to grab song title info from my xbox media center every 5 seconds.
    - John H
    * PROMIXIAN TO THE CORE! * (NetRemote2WholeHomePro + Girder5WholeHomePro + USB-UIRT + Touchscreens + WirelessControlSystems + ANNA) == AutomationHeaven
    - "IthinkI'mgoingtobantheuseofthespacebarinfuture..."

  4. #4
    Join Date
    Oct 2007
    Posts
    3

    Default Thanks

    Yesterday i found a problem in posting thread, so did not reply in time.

    Harleydude:
    The problem is the keystroke will show up one by one without a break, that means the timer is not working.

    NeoMorph:
    Yes, your code is working! and give me a better understanding of the function. Thanks.
    Last edited by PengLi; October 4th, 2007 at 09:29 AM.

  5. #5
    Join Date
    Nov 2005
    Location
    Redditch, UK
    Posts
    957

    Default

    Quote Originally Posted by PengLi View Post
    NeoMorph:
    Yes, your code is working! and give me a better understanding of the function. Thanks.
    You're welcome. I've asked more than my fair share of questions here so if I can help people I do.

    One note.. do not make your timer a local as they work only up until the first garbage collection which is when they die because Girder doesn't think they are being used.

    So....
    Code:
    local t = gir.CreateTimer("", eventFunction, "", true, true)
    t:Arm(5000)
    ... looks the same but will only work for a short time. Just thought you should know.
    - John H
    * PROMIXIAN TO THE CORE! * (NetRemote2WholeHomePro + Girder5WholeHomePro + USB-UIRT + Touchscreens + WirelessControlSystems + ANNA) == AutomationHeaven
    - "IthinkI'mgoingtobantheuseofthespacebarinfuture..."

  6. #6
    Join Date
    Oct 2007
    Posts
    3

    Default

    Get another problem

    I want to stop the recursive action by using <F11> to reboot the engine (because i can not find other ways to do it except for closing Girder). And i try to use an script action as

    gir.TriggerEventEx("7A000000", 202, 0)

    To send a <F11> to Girder. When i hit the <F11> directly, the action stops but the script action did not work, the <F11> was sent but the action was remain running. Just wonder why? and if there are other ways to stop a running action? Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •