Skip to content

Commit 98ebfc1

Browse files
authored
Implement os.sleep
This shouldn't be too hard. Ripped code straight from OpenOS, and completely untested.
1 parent 5e213e5 commit 98ebfc1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

miniOS/minios.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,16 @@ filesystem = fs_code()
11611161
fs = filesystem
11621162
keyboard = dofile("keyboard.lua")
11631163
term = terminal_code()
1164+
1165+
-- set up other libraries...
1166+
os.sleep = function(timeout)
1167+
checkArg(1, timeout, "number", "nil")
1168+
local deadline = computer.uptime() + (timeout or 0)
1169+
repeat
1170+
event.pull(deadline - computer.uptime())
1171+
until computer.uptime() >= deadline
1172+
end
1173+
11641174
--set up terminal
11651175
if term.isAvailable() then
11661176
component.gpu.bind(component.screen.address)

0 commit comments

Comments
 (0)