diff --git a/Turtle/Wheat.lua b/Turtle/Wheat.lua index 94935f5..6e948e4 100644 --- a/Turtle/Wheat.lua +++ b/Turtle/Wheat.lua @@ -52,4 +52,35 @@ function Wheat:selectPlantable(update) turtle.select(slot) return true 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 \ No newline at end of file