Compare commits
5 Commits
f53d5decf8
...
9c6d092cfc
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c6d092cfc | |||
| a122f2a849 | |||
| 3999ad8c6c | |||
| f99df4bf86 | |||
| 650aad0713 |
@@ -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)
|
||||
8
automate_farming/farming_db.lua
Normal file
8
automate_farming/farming_db.lua
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user