Update 'Controller/CropController.lua'
This commit is contained in:
parent
f21fd53133
commit
7827a83f31
@ -1,6 +1,6 @@
|
|||||||
wheatController = {}
|
CropController = {}
|
||||||
|
|
||||||
function wheatController:new(t)
|
function CropController:new(t)
|
||||||
t = t or {}
|
t = t or {}
|
||||||
setmetatable(t, self)
|
setmetatable(t, self)
|
||||||
self.__index = self
|
self.__index = self
|
||||||
@ -8,7 +8,7 @@ function wheatController:new(t)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function toMatrix(str)
|
function CropController:toMatrix(str)
|
||||||
local matrix = {}
|
local matrix = {}
|
||||||
assert(type(str) == "string")
|
assert(type(str) == "string")
|
||||||
assert(str:sub(1,1) == "{", "the string must begin with a \"{\"")
|
assert(str:sub(1,1) == "{", "the string must begin with a \"{\"")
|
||||||
@ -44,7 +44,7 @@ function toMatrix(str)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function toArray(str)
|
function CropController:toArray(str)
|
||||||
local len = str:len()
|
local len = str:len()
|
||||||
local comma = str:find(",")
|
local comma = str:find(",")
|
||||||
local arr = {}
|
local arr = {}
|
||||||
@ -60,13 +60,13 @@ function toArray(str)
|
|||||||
return arr
|
return arr
|
||||||
end
|
end
|
||||||
|
|
||||||
function wheatController:sendMessage(id, message, protocol)
|
function CropController:sendMessage(id, message, protocol)
|
||||||
rednet.send(id, message, protocol)
|
rednet.send(id, message, protocol)
|
||||||
local id2, message2 = rednet.receive("received", 1)
|
local id2, message2 = rednet.receive("received", 1)
|
||||||
return message == message2
|
return message == message2
|
||||||
end
|
end
|
||||||
|
|
||||||
function wheatController:doAction(id, message, protocol)
|
function CropController:doAction(id, message, protocol)
|
||||||
self:sendMessage(id, message, protocol)
|
self:sendMessage(id, message, protocol)
|
||||||
local id2, message2, protocol2
|
local id2, message2, protocol2
|
||||||
repeat
|
repeat
|
||||||
@ -75,6 +75,6 @@ function wheatController:doAction(id, message, protocol)
|
|||||||
return protocol2 == "confirm", message2
|
return protocol2 == "confirm", message2
|
||||||
end
|
end
|
||||||
|
|
||||||
function wheatController:setSlaveID(id)
|
function CropController:setSlaveID(id)
|
||||||
self.slaveID = id
|
self.slaveID = id
|
||||||
end
|
end
|
Loading…
x
Reference in New Issue
Block a user