Results 1 to 7 of 7

Thread: LUA Newbie: TriggerEvent depending on Current Time

  1. #1
    Join Date
    May 2004
    Location
    Darmstadt Germany
    Posts
    306

    Default LUA Newbie: TriggerEvent depending on Current Time

    Hi Guys,

    I am a LUA Newbie and have done the first successfull steps with skripting. But there is one thing I cannot solve.

    My Task:
    I want to switch on TV backgroung light when TV is switched on between 8:00 pm and 06:00 am. Sofar I have a command which uses LUA with TriggerEvent to put on the light (x10 works great) and a related Event which is activated when the TV is started. Can someone help me with the skript?

    Thanks,

    mhund

  2. #2
    Join Date
    Dec 2001
    Posts
    11,560

    Default

    Sure,

    Search here for the date function.

    You will do something like
    Code:
    if date &#40;"$H"&#41; > "18" and date &#40;"$H"&#41; < "6" then
      TriggerEvent &#40;"turnonbacklight"&#41;
    end

  3. #3
    Join Date
    May 2004
    Location
    Darmstadt Germany
    Posts
    306

    Default

    Hi Mike,

    thanks for your help. I changed the skript a little bit to adjust the variable types and it works great. This way I learn more and more about LUA.

    thanks,

    mhund

  4. #4
    Join Date
    Dec 2001
    Posts
    11,560

    Default

    Sure,

    Please post some of your script here when done, so others can see how to use the date function in an if statement.

  5. #5
    Join Date
    May 2004
    Location
    Darmstadt Germany
    Posts
    306

    Default

    Hi Mike,

    I follow your idea and write down my short skript:

    Code:
    if tonumber&#40;date &#40;"%H"&#41;&#41; > 19 or tonumber&#40;date &#40;"%H"&#41;&#41; < 6 then
      TriggerEvent &#40;"IE Light TV On",203&#41;
    end
    To compare the numbers and not the ASCII Codes, I changed the data type to integer (number). The date format qualifier has to start with %, not with $.

    Girder is a great thing with skripting,

    mhund

  6. #6
    Join Date
    May 2004
    Posts
    2,577

    Default

    Code:
    if tonumber&#40;date &#40;"%H"&#41;&#41; > 19 or tonumber&#40;date &#40;"%H"&#41;&#41; < 6 then 
      TriggerEvent &#40;"IE Light TV On",203&#41; 
    end
    what is the 203 on the second line? I thought it was supposed to be 18.

    :-?

  7. #7
    Join Date
    May 2004
    Location
    Darmstadt Germany
    Posts
    306

    Default

    Quote Originally Posted by quixote
    Code:
    if tonumber&#40;date &#40;"%H"&#41;&#41; > 19 or tonumber&#40;date &#40;"%H"&#41;&#41; < 6 then 
      TriggerEvent &#40;"IE Light TV On",203&#41; 
    end
    what is the 203 on the second line? I thought it was supposed to be 18.

    :-?
    Hi,

    with the TriggerEvent ("IE Light TV On",203) I trigger an internet event because the x10 module for switching the light is located on a different machine. The 203 is the girder device ID for the Internet Event Server.

    regards,

    mhund

Posting Permissions

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