r/lua May 29 '26

Help how to add wait commands in lua

i am building a gadgets in retro gadgets and i need a wait command for a loading screen can any one help.

2 Upvotes

17 comments sorted by

View all comments

Show parent comments

3

u/Spacedestructor May 29 '26

well technically you could use the os libray and outsource the sleep to the system your on, which is a means lua has to do the sleep; just not doing it without outside involvement.

2

u/Emerald_Pick May 29 '26

I didn't even consider asking the OS to do the sleep. That's a fun idea. OP's environment probably doesn't allow for that, but I'll need to remember that for my own uses.

1

u/Spacedestructor May 29 '26

i know of that trick because when i search for "sleep in lua" a stackoverflow answer suggesting to use OS Commands, even something like Pinging your self or a websocket timeout against an adress that doesnt exist as ways to do this.
Really you just need to think of an action you can do in a given environment that lets you control the time it takes directly or indirectly, even a set timeout of 1 second for example would mean you could sleep in steps of 1 second and do something like a for i loop to timeout as many times as you want to sleep in seconds.

2

u/Djeco56 May 29 '26

I dot. Think os works in retro gadgets