Thread: Delay in Lua?
-
November 8th, 2020, 17:08 #1
- Join Date
- Jan 2020
- Posts
- 222
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, 17:58 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,558
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
-
November 14th, 2020, 04:04 #3
- Join Date
- Jan 2020
- Posts
- 222
Yeah, os.clock() works but does delay the whole engine. Too bad.
-
November 14th, 2020, 06:27 #4---
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.
-
November 14th, 2020, 14: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(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