Thread: Delay in Lua?
-
November 8th, 2020, 18:08 #1
- Join Date
- Jan 2020
- Posts
- 216
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
Thoughts?
-
November 8th, 2020, 18:58 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 15,066
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,
JPGFG Wish List - http://fgapp.idea.informer.com/
-
November 14th, 2020, 05:04 #3
- Join Date
- Jan 2020
- Posts
- 216
Yeah, os.clock() works but does delay the whole engine. Too bad.
-
November 14th, 2020, 07:27 #4---
Fantasy Grounds AD&D Content Bundle (All The AD&D Content)
Coding the Official AD&D Ruleset
Documentation for AD&D 2E ruleset.
My Twitch Channel for AD&D and FG related streams (See schedule for live days)
My YouTube for FG related Tutorials and AD&D Actual Plays
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
-
November 14th, 2020, 15:24 #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 Extension(FGU 5E):
Paid Extension(FGU 5E):
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks