Added autoupdater

This commit is contained in:
LDDestroier 2019-02-28 23:47:51 -05:00 committed by GitHub
parent ea50b6b7a7
commit 2bd56706e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 2 deletions

View File

@ -130,9 +130,10 @@ local function interpretArgs(tInput, tArgs)
end
local argData = {
["skynet"] = false, -- use Skynet HTTP multiplayer
["quick"] = false, -- start one game immediately
["skynet"] = false, -- use Skynet HTTP multiplayer
["quick"] = false, -- start one game immediately
["griddemo"] = false, -- only move the grid
["--update"] = false, -- updates TRON to the latest version
["--gridID"] = "number" -- grid ID to use
}
@ -235,6 +236,7 @@ local argList = interpretArgs({...}, argData)
local useSkynet = argList["skynet"]
local useOnce = argList["quick"]
local doGridDemo = argList["griddemo"]
local doUpdateGame = argList["--update"]
if gridList[argList["--gridID"]] then
gridID = argList["--gridID"]
end
@ -1590,6 +1592,23 @@ local main = function()
end
end
if doUpdateGame then
print("Downloading...")
local net = http.get("https://github.com/LDDestroier/CC/raw/master/tron.lua")
if net then
local file = fs.open(shell.getRunningProgram(), "w")
file.write(net.readAll())
file.close()
print("Updated!")
else
printError("Couldn't update!")
end
if useOnce then
return
else
sleep(0.2)
end
end
if doGridDemo then
parallel.waitForAny(function()
local step, gsX, gsY = 0, 0, 0