Add installer/updater
This commit is contained in:
@ -104,6 +104,11 @@ function handlers.handleDisconnectButton(eventType, side, x, y)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Only process if stargate is actually connected
|
||||||
|
if not gate.isStargateConnected() then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
-- Check if clicking disconnect button (bottom-right corner)
|
-- Check if clicking disconnect button (bottom-right corner)
|
||||||
if y >= 17 and y <= 19 and x >= 20 and x <= 28 then
|
if y >= 17 and y <= 19 and x >= 20 and x <= 28 then
|
||||||
gate.disconnectStargate()
|
gate.disconnectStargate()
|
||||||
|
|||||||
107
install.lua
Normal file
107
install.lua
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
--[[
|
||||||
|
Stargate Control System - Installer
|
||||||
|
Downloads and installs all necessary files from the git repository
|
||||||
|
]]
|
||||||
|
|
||||||
|
local baseUrl = "https://git.munebase.dev/Munelit/StargateControl/raw/branch/master/"
|
||||||
|
|
||||||
|
local files = {
|
||||||
|
-- Core files (always download)
|
||||||
|
"startup.lua",
|
||||||
|
"addresses.lua",
|
||||||
|
"utils.lua",
|
||||||
|
"display.lua",
|
||||||
|
"events.lua",
|
||||||
|
"handlers.lua",
|
||||||
|
|
||||||
|
-- Config file (only download if doesn't exist)
|
||||||
|
config = "config.lua"
|
||||||
|
}
|
||||||
|
|
||||||
|
local function downloadFile(filename, url)
|
||||||
|
print("Downloading " .. filename .. "...")
|
||||||
|
|
||||||
|
-- Delete existing file first (to ensure clean update)
|
||||||
|
if fs.exists(filename) then
|
||||||
|
fs.delete(filename)
|
||||||
|
end
|
||||||
|
|
||||||
|
local response = http.get(url)
|
||||||
|
|
||||||
|
if response then
|
||||||
|
local content = response.readAll()
|
||||||
|
response.close()
|
||||||
|
|
||||||
|
local file = fs.open(filename, "w")
|
||||||
|
if file then
|
||||||
|
file.write(content)
|
||||||
|
file.close()
|
||||||
|
print(" [OK] " .. filename)
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
print(" [FAIL] Could not write " .. filename)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print(" [FAIL] Could not download " .. filename)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
print("========================================")
|
||||||
|
print(" Stargate Control System Installer")
|
||||||
|
print("========================================")
|
||||||
|
print("")
|
||||||
|
|
||||||
|
-- Check if HTTP is enabled
|
||||||
|
if not http then
|
||||||
|
print("ERROR: HTTP is not enabled!")
|
||||||
|
print("Please enable it in the ComputerCraft config.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local success = 0
|
||||||
|
local failed = 0
|
||||||
|
|
||||||
|
-- Download core files
|
||||||
|
for _, filename in ipairs(files) do
|
||||||
|
local url = baseUrl .. filename
|
||||||
|
if downloadFile(filename, url) then
|
||||||
|
success = success + 1
|
||||||
|
else
|
||||||
|
failed = failed + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Download config file only if it doesn't exist
|
||||||
|
if fs.exists("config.lua") then
|
||||||
|
print("Config file already exists - skipping")
|
||||||
|
print(" [SKIP] config.lua")
|
||||||
|
else
|
||||||
|
local url = baseUrl .. "config.lua"
|
||||||
|
if downloadFile("config.lua", url) then
|
||||||
|
success = success + 1
|
||||||
|
else
|
||||||
|
failed = failed + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
print("")
|
||||||
|
print("========================================")
|
||||||
|
print("Installation complete!")
|
||||||
|
print(" Success: " .. success)
|
||||||
|
print(" Failed: " .. failed)
|
||||||
|
print("========================================")
|
||||||
|
print("")
|
||||||
|
|
||||||
|
if failed > 0 then
|
||||||
|
print("WARNING: Some files failed to download.")
|
||||||
|
print("Please check your internet connection and try again.")
|
||||||
|
else
|
||||||
|
print("All files downloaded successfully!")
|
||||||
|
print("")
|
||||||
|
print("To start the program, run: startup")
|
||||||
|
print("")
|
||||||
|
print("Note: You may need to configure config.lua")
|
||||||
|
print("with your specific settings before running.")
|
||||||
|
end
|
||||||
@ -516,7 +516,7 @@ local function selectGateFromList()
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check back button (x: 23-28, y: 17-19)
|
-- Check back button (x: 23-28, y: 17-19)
|
||||||
if not dialing and sely >= 17 and sely <= 19 and selx >= 23 and selx <= 28 then
|
if not dialing and sely >= 17 and sely <= 19 and selx >= 23 and selx <= 28 then
|
||||||
selecting = false
|
selecting = false
|
||||||
|
|||||||
Reference in New Issue
Block a user