Compare commits

...

5 Commits

2 changed files with 51 additions and 4 deletions

View File

@@ -1,8 +1,47 @@
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 networkChannel = 420
if (databaseModem.isOpen(networkChannel)) then databaseModem.close(networkChannel) end
databaseModem.open(networkChannel)
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 listenForFieldDataRequests()
while true do
local event, _, incomingChannel, replyChannel, message, _ = os.pullEvent("modem_message")
if (incomingChannel == fieldDataChannel) then
local database = dofile("/" .. databaseStorage.getMountPath() .. "/farming_db.lua")
database = nil
end
end
end
local function listenForFieldSetups()
while true do
local event, _, incomingChannel, replyChannel, message, _ = os.pullEvent("modem_message")
if (incomingChannel == setupFieldChannel) then
end
end
end
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
parallel.waitForAny(listenForFieldDataRequests, listenForFieldSetups, listenForDiskEject, listenForPeripheralDetach)

View File

@@ -0,0 +1,8 @@
return {
["Wheat Farming 01"] = {
field = {
vector.new(0.1, 0.1, 0.1), vector.new(0.2, 0.2, 0.2)
},
refuel_station = vector.new(0, 0, 0)
}
}