2023-01-03 18:33:10 +00:00

38 lines
946 B
Lua

require("spruceCut")
require("Wood")
local path = "/treeAlpha2/properties.txt"
local hostPC = 30
sleep(1)
rednet.open("right")
rednet.send(hostPC, "started", "spruceCut")
local tree = Wood:new()
function answer(message, id)
sleep(0.1)
rednet.send(id, message, "received")
if(message == "init") then
tree:readConfig(path)
tree:autoHome()
rednet.send(id, "init finished", "confirm")
elseif(message == "checkTree") then
rednet.send(id, tree:checkTree(), "confirm")
elseif(message == "plantTree") then
tree:plantTree()
rednet.send(id, "plant finished", "confirm")
elseif(message == "cutTree") then
tree:cutTree()
rednet.send(id, "cut finished", "confirm")
end
rednet.send(id, "could not resolve message", "error")
end
local function main()
while true do
local id, message = rednet.receive()
answer(message, id)
end
end
main()