turtle/startup.lua
2025-06-27 14:26:58 +01:00

40 lines
908 B
Lua

local filesToDownload = {
"behavior.lua",
"status.lua",
"logger.lua"
}
local baseURL = "https://git.fisher.network/cc/turtle/raw/main/"
-- Helper to download a file
local function downloadFile(filename)
local url = baseURL .. filename
local res = http.get(url)
if not res then
error("Failed to download " .. filename)
end
local content = res.readAll()
res.close()
local file = fs.open(filename, "w")
file.write(content)
file.close()
print("Downloaded " .. filename)
end
-- Download each file
for _, filename in ipairs(filesToDownload) do
-- remove each file first
fs.remove(filename)
downloadFile(filename)
end
local behavior = require("behavior")
local status = require("status")
-- Run behavior and status reporting in parallel
parallel.waitForAny(
behavior.run,
function() status.reportStatus(behavior.getStatus) end
)