-- main.lua
--(( APIs ))--
os.loadAPI("util")
os.loadAPI("inv")
os.loadAPI("mail")
--(( Settings ))--
local rsOutput = "left"
-- seconds between each tick
local tickDelay = 5
-- seconds between each update
local updateWait = 1
--(( Variables ))--
--(( Functions ))--
local function handleDisk()
local data = mail.readMail()
if data.err then
if data.err ~= "missing_item" then
print(mail.err[data.err])
inv.emptyDrive()
end
else
mail.writeMail(data)
inv.emptyDrive(inv.getDirection(data.sender))
end
end
local function tickRedstone()
rs.setOutput(rsOutput, os.clock() % tickDelay / tickDelay > 0.5)
end
local function update()
handleDisk()
tickRedstone()
end
--(( Mane program ))--
-- empty the printer just in case
pcall(mail.getPrinter().endPage)
inv.emptyDropper()
-- Main loop
while true do
update()
sleep(updateWait)
end
-- eof
Comments