This commit is contained in:
Laurie Fisher 2025-06-27 14:42:20 +01:00
parent 103e0ea17d
commit 5238e31018
Signed by: PinkEyedOrphan
GPG Key ID: 7F827B68147AEE76
3 changed files with 7 additions and 62 deletions

View File

@ -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

View File

@ -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

View File

@ -1,7 +1,7 @@
local filesToDownload = { local filesToDownload = {
"behavior.lua", "libs/behavior.lua",
"status.lua", "libs/status.lua",
"logger.lua" "libs/logger.lua"
} }
local baseURL = "https://git.fisher.network/cc/turtle/raw/main/" local baseURL = "https://git.fisher.network/cc/turtle/raw/main/"
@ -24,6 +24,7 @@ local function downloadFile(filename)
end end
-- Download each file -- Download each file
if not fs.exists("libs") then fs.makeDir("libs") end
for _, filename in ipairs(filesToDownload) do for _, filename in ipairs(filesToDownload) do
-- remove each file first -- remove each file first
if fs.exists(filename) then if fs.exists(filename) then
@ -33,8 +34,9 @@ for _, filename in ipairs(filesToDownload) do
downloadFile(filename) downloadFile(filename)
end end
local behavior = require("behavior") local tutil = require("libs.turtleutils")
local status = require("status") local behavior = require("libs.behavior")
local status = require("libs.status")
-- Run behavior and status reporting in parallel -- Run behavior and status reporting in parallel
parallel.waitForAny( parallel.waitForAny(