feat(farming/database): started main logic loop

This commit is contained in:
2025-05-13 22:01:32 +02:00
parent 3999ad8c6c
commit a122f2a849

View File

@@ -1,6 +1,5 @@
local databaseStorage = peripheral.find("drive") or error("No drive attached", 0) 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 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 databaseModem = peripheral.find("modem") or error("No modem attached", 0)
local fieldDataChannel = 420 -- Request Field Data Channel local fieldDataChannel = 420 -- Request Field Data Channel
@@ -9,6 +8,28 @@ if (databaseModem.isOpen(fieldDataChannel) or databaseModem.isOpen(setupFieldCha
databaseModem.open(fieldDataChannel) databaseModem.open(fieldDataChannel)
databaseModem.open(setupFieldChannel) 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() local function listenForDiskEject()
repeat repeat
local _, side = os.pullEvent("disk_eject") local _, side = os.pullEvent("disk_eject")