From 2931ca0816ea633c0e26c5e2fab4e54d38e4cd49 Mon Sep 17 00:00:00 2001 From: manuel Date: Sun, 8 Jan 2023 16:19:12 +0000 Subject: [PATCH] Update 'Turtle/Wheat.lua' --- Turtle/Wheat.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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