25 lines
994 B
Lua
25 lines
994 B
Lua
local databaseStorage = peripheral.find("drive") or error("No drive attached", 0)
|
|
if (databaseStorage.isDiskPresent() == false or databaseStorage.getDiskLabel() ~= "Farming Data") then error("Missing or wrong drive", 0) end
|
|
local databasePath = databaseStorage.getMountPath()
|
|
|
|
local databaseModem = peripheral.find("modem") or error("No modem attached", 0)
|
|
local fieldDataChannel = 420 -- Request Field Data Channel
|
|
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
|