Delete 'Controller/wheatDaemon.lua'
This commit is contained in:
parent
2b2305d02c
commit
4bee1219a1
@ -1,72 +0,0 @@
|
||||
require("Wheat")
|
||||
local path = "/wheat/config.txt"
|
||||
local hostPC = 30
|
||||
sleep(1)
|
||||
rednet.open("right")
|
||||
rednet.send(hostPC, "started", "spruceCut")
|
||||
local wheat = Wheat:new()
|
||||
|
||||
function toMatrix(str)
|
||||
local matrix = {}
|
||||
assert(type(str) == "string")
|
||||
assert(str:sub(1,1) == "{", "the string must begin with a \"{\"")
|
||||
local len = str:len()
|
||||
assert(str:sub(len,len) == "}", "the string must end with a \"}\"")
|
||||
local s1, ob = str:gsub("{", "{")
|
||||
local s2, cb = str:gsub("}", "}")
|
||||
assert(ob == cb, "the string must have the same amount of opening brackets as closing brackets")
|
||||
|
||||
str = str:sub(2, len - 1)
|
||||
len = len - 2
|
||||
|
||||
if(str:sub(1,1) == "{") then
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function toArray(str)
|
||||
local len = str:len()
|
||||
local comma = str:sub(",")
|
||||
local arr = {}
|
||||
while(type(comma)=="number") do
|
||||
arr[#arr+1] = str:sub(1, comma-1)
|
||||
str = str:sub(comma + 1, len)
|
||||
len = str:len()
|
||||
comma = str:sub(",")
|
||||
end
|
||||
return arr
|
||||
end
|
||||
|
||||
function answer(message, id)
|
||||
sleep(0.1)
|
||||
rednet.send(id, message, "received")
|
||||
sleep(0.1)
|
||||
if(message == "init") then
|
||||
wheat:readConfig(path)
|
||||
wheat:createMatrix()
|
||||
rednet.send(id, "init finished", "confirm")
|
||||
elseif(message == "getMatrix") then
|
||||
rednet.send(id, wheat:getMatrixString(), "confirm")
|
||||
elseif(message == "plantCrop") then
|
||||
wheat:plantAll()
|
||||
rednet.send(id, "plant finished", "confirm")
|
||||
elseif(message == "harvest") then
|
||||
wheat:harvestAll()
|
||||
rednet.send(id, "harvest finished", "confirm")
|
||||
elseif(message == "getFuelLevel") then
|
||||
rednet.send(id, tostring(wheat:getFuelLevel()), "confirm")
|
||||
elseif(message == "refuel") then
|
||||
--wheat:refuel()
|
||||
rednet.send(id, "refueled", "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()
|
Loading…
x
Reference in New Issue
Block a user