DICE PACKS BUNDLE

Thread: Delay in Lua?

  1. #1

    Delay in Lua?

    Does anyone know if there is a way to implement a visible delay using Lua?

    I've tried with os.clock like this but it doesn't delay in execution order, it seems to delay the whole function it's in from executing (even if this is at the end of the function):

    Code:
    			local start = os.clock();
    			while os.clock() - start < 1.0 do end
    I suspect it has something to do with how FG threads.

    Thoughts?

  2. #2
    There is no function to delay the scripts. Because the UI fires events and interacts with the Lua engine all the time and change the state of objects, it is single threaded (or else lots of assumptions and code would break). So, you can't introduce delays into any Lua code without delaying the whole engine.

    The alternate answer is probably some sort of timer support in the Lua coding; but that's not currently on our radar.

    Regards,
    JPG

  3. #3
    Yeah, os.clock() works but does delay the whole engine. Too bad.

  4. #4
    Quote Originally Posted by zuilin View Post
    Yeah, os.clock() works but does delay the whole engine. Too bad.
    It would be really nice to have a non-blocking timer event system.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  5. #5
    Think of it as a single thread going through things you want done - and if you want to keep doing "other things" and come back to this thing your trying to delay - you'd have to constantly have things checking that stored time to see "are we there yet?" periodically throughout your code - and then be able to do whatever it was you delayed whenever that happened. Not pretty. But I know no other way. If you find one make sure you update this thread.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

Thread Information

Users Browsing this Thread

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in