Update 'Turtle/Wheat.lua'
This commit is contained in:
parent
49c685b02f
commit
2931ca0816
@ -52,4 +52,35 @@ function Wheat:selectPlantable(update)
|
|||||||
turtle.select(slot)
|
turtle.select(slot)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Wheat:readConfig(path)
|
||||||
|
-- reading configFile into a table
|
||||||
|
if (path == nil) then
|
||||||
|
term.write("init must have a path for the config file as argument")
|
||||||
|
return -1
|
||||||
|
end
|
||||||
|
if (type(path) ~= "string") then
|
||||||
|
term.write("invalid argument")
|
||||||
|
return -1
|
||||||
|
end
|
||||||
|
if (not fs.exists(path)) then
|
||||||
|
term.write("could not find config file \n please make sure it exists and the path is correct")
|
||||||
|
return -1
|
||||||
|
end
|
||||||
|
local file = fs.open(path, "r")
|
||||||
|
local config = {}
|
||||||
|
while true do
|
||||||
|
local line = file.readLine()
|
||||||
|
if not line then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
local numLine = tonumber(line)
|
||||||
|
config[#config+1] = numLine
|
||||||
|
end
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
self.homePos = {config[1], config[2], config[3], config[4]}
|
||||||
|
self.length = config[5]
|
||||||
|
self.width = config[6]
|
||||||
end
|
end
|
Loading…
x
Reference in New Issue
Block a user