User Tag List

Results 1 to 6 of 6

Thread: [Eluna] call a function every second

  1. #1
    Lurking Member
    Join Date
    Jan 2017
    Posts
    7
    XP
    48
    Level
    1
    Thanks
    2
    Thanked 0 Times in 0 Posts

    [Eluna] call a function every second

    Hey,

    i'm currently working on a script based on the servers time. i want to register a handler on server startup that creates an infinite function call loop with time offset t. within this function i want to check if currTime >= defTime then...

    Do you know some example script or shared script i can look into to learn off? I've already checked the eluna api docs but i did not find something useful.

    thanks

  2. #2
    Moderator / Eluna Dev <span style='color: #FF0000'><span class='glow_8B0000'>Rochet2</span></span>'s Avatar
    Join Date
    Apr 2013
    Location
    Finland
    Posts
    1,859
    XP
    13,487
    Level
    35
    Thanks
    95
    Thanked 591 Times in 418 Posts
    http://eluna.emudevs.com/Global/CreateLuaEvent.html
    http://eluna.emudevs.com/WorldObject/RegisterEvent.html

    Both are used in similar way, but the second one also passes the world object that the event was registered for to the function that is executed when the timed event is executed.

    Example:

    Code:
    local function MyTimedFunction(eventid, delay, repeats)
        print("A second has passed")
    end
    
    -- make the timed event when the script is run on startup or reload
    CreateLuaEvent(MyTimedFunction, t, 0) -- t is your time in ms
    If you really want to use the time diff method that you seem to write about in your main post, then you can try some of these:
    http://eluna.emudevs.com/Global/Regi...tureEvent.html
    CREATURE_EVENT_ON_AIUPDATE = 7, // (event, creature, diff)

    http://eluna.emudevs.com/Global/RegisterMapEvent.html
    INSTANCE_EVENT_ON_UPDATE = 3, // (event, map, diff)

    http://eluna.emudevs.com/Global/Regi...rverEvent.html
    WORLD_EVENT_ON_UPDATE = 13, // (event, diff)

    You most likely want to use the last or the first one of these
    Awards:
    Support LOL Scripter Facepalm! Raffle Winner
    rochet2.github.io - Home of great codes

  3. The Following User Says Thank You to Rochet2 For This Useful Post:


  4. #3
    Original Poster
    Lurking Member
    Join Date
    Jan 2017
    Posts
    7
    XP
    48
    Level
    1
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks for your fast reply, thats exactly what i was looking for.
    Can you provide more information related to the 3 events you've mentioned? I have re-read their doc's pages but i can not find any information on when they gett called. That would be an useful addition to the doc's too.

    thanks

  5. #4
    Founder <span style='color: #FF4500'>Tommy</span>'s Avatar
    Join Date
    Apr 2013
    Posts
    7,391
    XP
    3,449,104
    Level
    378
    Thanks
    889
    Thanked 1,856 Times in 1,119 Posts
    Quote Originally Posted by Cryhme187 View Post
    Thanks for your fast reply, thats exactly what i was looking for.
    Can you provide more information related to the 3 events you've mentioned? I have re-read their doc's pages but i can not find any information on when they gett called. That would be an useful addition to the doc's too.

    thanks
    They are update events so they are called every x tick after registering the said event(s). You could also test by printing test text to console/ingame after registering an event.

  6. #5
    Moderator / Eluna Dev <span style='color: #FF0000'><span class='glow_8B0000'>Rochet2</span></span>'s Avatar
    Join Date
    Apr 2013
    Location
    Finland
    Posts
    1,859
    XP
    13,487
    Level
    35
    Thanks
    95
    Thanked 591 Times in 418 Posts
    In addition to what tommy said you should know that
    CREATURE_EVENT_ON_AIUPDATE = 7, // (event, creature, diff)
    is being called when a creature is in view of a player (exists ingame and is loaded)
    If a creature is in some other plain of visibility even if a player is next to it, it may not be updated or loaded.

    INSTANCE_EVENT_ON_UPDATE = 3, // (event, map, diff)
    is being called when a map is loaded and active

    WORLD_EVENT_ON_UPDATE = 13, // (event, diff)
    is being called all the time no matter what circumstances
    Awards:
    Support LOL Scripter Facepalm! Raffle Winner
    rochet2.github.io - Home of great codes

  7. The Following User Says Thank You to Rochet2 For This Useful Post:


  8. #6
    Original Poster
    Lurking Member
    Join Date
    Jan 2017
    Posts
    7
    XP
    48
    Level
    1
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thanks, again exactly what i needed. I asked because i dont want to generate too much load by the timediff check. Currently i'm thinking about running it with an 5 minutes interval as it has only to precise to the day.

    thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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