feat(farming/database): listen for disk or peripheral eject
This commit is contained in:
@@ -8,3 +8,17 @@ local setupFieldChannel = 421 -- Setup Field Channel
|
||||
if (databaseModem.isOpen(fieldDataChannel) or databaseModem.isOpen(setupFieldChannel)) then databaseModem.closeAll() end
|
||||
databaseModem.open(fieldDataChannel)
|
||||
databaseModem.open(setupFieldChannel)
|
||||
|
||||
local function listenForDiskEject()
|
||||
repeat
|
||||
local _, side = os.pullEvent("disk_eject")
|
||||
until side ~= nil
|
||||
error("Disk was ejected!")
|
||||
end
|
||||
|
||||
local function listenForPeripheralDetach()
|
||||
repeat
|
||||
local _, side = os.pullEvent("peripheral_detach")
|
||||
until side ~= nil
|
||||
error("Modem was removed!")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user