Files
remoteturtle/startup_turtle.lua

70 lines
1.9 KiB
Lua

-- Turtle Startup Script
-- Automatically downloads and runs the latest turtle.lua from git
local SCRIPT_URL = "https://git.spatulaa.com/MayaTheShy/remoteturtle/raw/branch/master/turtle.lua"
local SCRIPT_NAME = "turtle.lua"
print("========================================")
print(" TURTLE AUTO-UPDATER")
print("========================================")
print("")
-- Remove old version
if fs.exists(SCRIPT_NAME) then
print("Removing old version...")
fs.delete(SCRIPT_NAME)
end
-- Download latest version
print("Downloading latest version...")
print("URL: " .. SCRIPT_URL)
local response = http.get(SCRIPT_URL)
if response then
local content = response.readAll()
response.close()
-- Save to file
local file = fs.open(SCRIPT_NAME, "w")
file.write(content)
file.close()
print("✓ Download successful!")
print("")
print("Starting turtle program...")
sleep(1)
-- Run the script with error handling
local success, error = pcall(function()
shell.run(SCRIPT_NAME)
end)
if not success then
print("")
print("========================================")
print(" ERROR OCCURRED!")
print("========================================")
print(error)
print("")
print("Press any key to see error details...")
os.pullEvent("key")
end
else
print("✗ Download failed!")
print("Please check:")
print(" - Internet connection")
print(" - URL is correct")
print(" - HTTP API is enabled")
print("")
print("Falling back to existing script...")
-- Try to run existing version if download fails
if fs.exists(SCRIPT_NAME) then
shell.run(SCRIPT_NAME)
else
print("No existing script found!")
print("Please download manually:")
print(" wget " .. SCRIPT_URL .. " " .. SCRIPT_NAME)
end
end