1
0
mirror of https://github.com/20kdc/OC-KittenOS.git synced 2024-11-08 19:48:07 +11:00
OC-KittenOS/repository/apps/svc-ghostie.lua

37 lines
858 B
Lua

-- This is released into the public domain.
-- No warranty is provided, implied or otherwise.
-- svc-ghostie.lua : Ghostie the test ghost!
-- Authors: 20kdc
-- Since this should expect to be started on-demand,
-- take precautions here.
-- Specifically, register as soon as possible.
-- While not required, security dialogs can cause a timeout.
local r = neo.requireAccess("r.svc.ghostie", "ghost registration")
local waiting = 0
r(function (pkg, pid, sendSig)
-- just totally ignore the details
return function ()
neo.scheduleTimer(os.uptime() + 5 + (math.random() * 10))
waiting = waiting + 1
end
end)
local computer = neo.requireAccess("k.computer", "scare system")
while true do
local ev = coroutine.yield()
if ev == "k.timer" then
-- boo!
computer.beep(440, 1)
waiting = waiting - 1
if waiting == 0 then
return
end
end
end