diff --git a/behavior.lua b/behavior.lua deleted file mode 100644 index e4b2c68..0000000 --- a/behavior.lua +++ /dev/null @@ -1,28 +0,0 @@ -local M = {} - -local logger = require("logger") -local currentStatus = "idle" - -function M.getStatus() - return currentStatus -end - -function M.run() - while true do - currentStatus = "moving backward" - logger.log("Started moving backward") - for i = 1, 10 do - turtle.back() - sleep(0.5) - end - - currentStatus = "moving forward" - logger.log("Started moving forward") - for i = 1, 10 do - turtle.forward() - sleep(0.5) - end - end -end - -return M \ No newline at end of file diff --git a/logger.lua b/logger.lua deleted file mode 100644 index a232273..0000000 --- a/logger.lua +++ /dev/null @@ -1,29 +0,0 @@ -local M = {} - -local logLines = {} -local maxLines = 5 - -function M.log(msg) - local time = textutils.formatTime(os.time(), true) - local entry = string.format("[%s] %s", time, msg) - - table.insert(logLines, entry) - if #logLines > maxLines then - table.remove(logLines, 1) - end - - M.draw() -end - -function M.draw() - local w, h = term.getSize() - for i = 1, maxLines do - term.setCursorPos(1, h - maxLines + i) - term.clearLine() - if logLines[i] then - term.write(logLines[i]) - end - end -end - -return M \ No newline at end of file diff --git a/startup.lua b/startup.lua index 6224ab6..38321bd 100644 --- a/startup.lua +++ b/startup.lua @@ -1,7 +1,7 @@ local filesToDownload = { - "behavior.lua", - "status.lua", - "logger.lua" + "libs/behavior.lua", + "libs/status.lua", + "libs/logger.lua" } local baseURL = "https://git.fisher.network/cc/turtle/raw/main/" @@ -24,6 +24,7 @@ local function downloadFile(filename) end -- Download each file +if not fs.exists("libs") then fs.makeDir("libs") end for _, filename in ipairs(filesToDownload) do -- remove each file first if fs.exists(filename) then @@ -33,8 +34,9 @@ for _, filename in ipairs(filesToDownload) do downloadFile(filename) end -local behavior = require("behavior") -local status = require("status") +local tutil = require("libs.turtleutils") +local behavior = require("libs.behavior") +local status = require("libs.status") -- Run behavior and status reporting in parallel parallel.waitForAny(