0 of 0

File information

Last updated

Original upload

Created by

Dylbill

Uploaded by

dylbill

Virus scan

Safe to use

Tags for this mod

11 comments

  1. romanicles
    romanicles
    • premium
    • 11 kudos
    What is the benefit compared to the existing timer functions (RegisterForUpdate, RegisterForUpdateGameTime) ?
    Multiple timers would only make sense if there is a timer id, so I can identify which timer was triggered:
    SetTimer(intervall, myID)
    RegisterForTimer(myID,callback)

    Or even better:
    timerID = SetTimer(intervall, callback)
    PauseTimer(timerID)
    ContinueTimer(timerID)
    StopTimer(timerID)

    And a guarantee that it is thread safe : what will happen if the callback processing takes longer than the intervall? Is the callback called in a paralell thread, is it stacked, is it dropped?

    As a modder I whish to be able to control if it is stacked or dropped because I see uses cases for both variants. Example:

    SetStackedTimer(1min,updateStats)
    SetDropableTimer(6h,eating)
    SetDropableTimer(3h,drinking)

    Better naming required :-)

    More open questions:

    • what happens to the timer while player is in game menu?
    • what happens if the player leaves and reloads the game?
    • is the timer synchronized with the frame rate like most of the papyrus functions?
    1. dylbill
      dylbill
      • premium
      • 490 kudos
      The benefit right now is only for convenience. The idea came because someone asked in the forums how to do multiple timers on the same script. https://forums.nexusmods.com/index.php?/topic/11503763-multiple-registerforsingleupdategametimes-on-one-script/ . If you look at the example script provided, you can differentiate timers, but by object and not by ID. 

      The timers are threaded as they use mod events.
      What this does is create a new object reference using placeAtMe, then attaches the TimerObj script to it via ConsoleUtil. 
      The TimerObj script still uses RegisterForSingleUpdate and RegisterForSingleUpdateGameTime, but with OnUpdate it sends a mod event that your main script registers for. You could also use separate events for each timer you create if you wish.
    2. romanicles
      romanicles
      • premium
      • 11 kudos
      Ok: this means the timers are not persistent, right?
    3. romanicles
      romanicles
      • premium
      • 11 kudos
      With an ID aka separate callback I would see more benefit - because then I could do things that are pretty hard to do using plain papyrus
    4. dylbill
      dylbill
      • premium
      • 490 kudos
      They are persistent, but you can delete them with the DeleteTimer function. 
    5. dylbill
      dylbill
      • premium
      • 490 kudos
      Again, you can do separate callbacks. Use different events for TimerEvent and GameTimeTimerEvent

    6. romanicles
      romanicles
      • premium
      • 11 kudos
      If it is bound to an invisible object (PlaceAtMe), does it really fire even after the parent cell is unloaded?
    7. romanicles
      romanicles
      • premium
      • 11 kudos
      Don't get this (separate events), could you give an example?
      Is included...
    8. dylbill
      dylbill
      • premium
      • 490 kudos
      That's a good point, I haven't tested that. I'll have to get back to you
    9. romanicles
      romanicles
      • premium
      • 11 kudos
      BTW: Mod Event registrations are not persistent, so they need re-registration after OnPlayerLoadGame event
    10. dylbill
      dylbill
      • premium
      • 490 kudos
      Hey, yes Events are still called on the TimerObj even after the parent cell is unloaded. Also, it appears that mod events are persistent, I didn't have to re-register after loading a game. I tested by starting a gametime timer for 1 hour, saving then quitting to desktop, then loading the save and waiting an hour. The event still triggered.