Update 'Controller/CropController.lua'

This commit is contained in:
manuel 2023-01-12 07:48:41 +00:00
parent f21fd53133
commit 7827a83f31

View File

@ -1,6 +1,6 @@
wheatController = {}
CropController = {}
function wheatController:new(t)
function CropController:new(t)
t = t or {}
setmetatable(t, self)
self.__index = self
@ -8,7 +8,7 @@ function wheatController:new(t)
end
function toMatrix(str)
function CropController:toMatrix(str)
local matrix = {}
assert(type(str) == "string")
assert(str:sub(1,1) == "{", "the string must begin with a \"{\"")
@ -44,7 +44,7 @@ function toMatrix(str)
end
function toArray(str)
function CropController:toArray(str)
local len = str:len()
local comma = str:find(",")
local arr = {}
@ -60,13 +60,13 @@ function toArray(str)
return arr
end
function wheatController:sendMessage(id, message, protocol)
function CropController:sendMessage(id, message, protocol)
rednet.send(id, message, protocol)
local id2, message2 = rednet.receive("received", 1)
return message == message2
end
function wheatController:doAction(id, message, protocol)
function CropController:doAction(id, message, protocol)
self:sendMessage(id, message, protocol)
local id2, message2, protocol2
repeat
@ -75,6 +75,6 @@ function wheatController:doAction(id, message, protocol)
return protocol2 == "confirm", message2
end
function wheatController:setSlaveID(id)
function CropController:setSlaveID(id)
self.slaveID = id
end