Skip to content

Commit 211b81f

Browse files
committed
Attempt to fix
1 parent 7d9eac5 commit 211b81f

File tree

3 files changed

+1520
-1393
lines changed

3 files changed

+1520
-1393
lines changed

src/main/resources/assets/opencomputers/loot/network/data/bin/ping.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,14 @@ local stats = {
4747
}
4848

4949
local function doSleep()
50-
50+
local epsilon = 1e-6
5151
local deadline = computer.uptime() + (tonumber(options.i) or tonumber(options.interval) or 1)
5252
repeat
53-
event.pull(deadline - computer.uptime())
54-
until computer.uptime() >= deadline
53+
local remaining = deadline - computer.uptime()
54+
if remaining <= epsilon then break end
55+
56+
event.pull(math.max(remaining, 0.001))
57+
until computer.uptime() >= deadline - epsilon
5558
end
5659

5760
local function doPing()

src/main/resources/assets/opencomputers/loot/openos/boot/02_os.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ end
2525
function os.sleep(timeout)
2626
checkArg(1, timeout, "number", "nil")
2727
local deadline = computer.uptime() + (timeout or 0)
28+
local epsilon = 1e-6
2829
repeat
29-
event.pull(deadline - computer.uptime())
30-
until computer.uptime() >= deadline
30+
local remaining = deadline - computer.uptime()
31+
if remaining <= epsilon then break end
32+
33+
event.pull(math.max(remaining, 0.001))
34+
until computer.uptime() >= deadline - epsilon
3135
end
3236

3337
os.setenv("PATH", "/bin:/usr/bin:/home/bin:.")

0 commit comments

Comments
 (0)