Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local VERSION = 0.102
- local thisVersion = 0.0
- local moduleVersions = {}
- if fs.exists("versions.json") then
- local file = fs.open("versions.json","r")
- local data = textutils.unserialiseJSON(file.readAll())
- file.close()
- if data then moduleVersions = data end
- end
- thisVersion = moduleVersions["VERSION"] or thisVersion
- if thisVersion >= VERSION then return end
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.blue)
- print("SCHEM TURTLE INSTALLER",VERSION)
- --FCK PASTEBIN
- term.setTextColor(colors.white)
- print("---------------------------")
- local modules = {
- ["apis/stats.lua"]={"pavY2TuB",0.01},
- ["apis/refuel.lua"]={"H9gy2NR1",0.10},
- ["apis/mine.lua"]={"dYAtCsDW",0.02},
- ["apis/turt.lua"]={"K4WXuZY3",0.01},
- ["apis/pattern.lua"]={"yW8jFeZk",1.00},
- ["mine.lua"]={"kMQNPYyh",0.02},
- ["names.json"]={"JegectTG",0.01},
- ["startup/.updates.lua"]={"266b45Vr",0.03},
- ["ore_priority.json"]={"utRhXMhL",0.01},
- ["apis/names.lua"]={"MY23L2Cf",0.06},
- ["apis/docs.lua"]={"97XNLNEw",0.02},
- ["apis/schem.lua"]={"QePY5dHT",0.01},
- ["apis/libs/zzlib.lua"]={"A7SE0U1z",0.02},
- ["apis/libs/inflateBit32.lua"]={"DhJpTgbG",0.01},
- ["apis/screen.lua"]={"qudBZVpH",1.00},
- ["apis/encryption.lua"]={"0eYmhPMt",1.00}
- }
- local patterns = {
- ["test_pattern"] = "U6y91X5v",
- ["circle15"] = "mDBsciBr",
- ["amogus"] = "0zW5dFmS"
- }
- local function downloadModule(pastebinCode,name)
- if not pastebinCode or not name then return end
- term.setTextColor(colors.yellow)
- local x,y = term.getSize()
- for i=3,y do
- term.setCursorPos(1,i)
- term.clearLine()
- end
- term.setCursorPos(1,3)
- if fs.exists("downloads/"..name) then fs.delete("downloads/"..name) end
- print("Retrieving ".. string.gsub(name,"%.%a+",""))
- shell.run("pastebin get "..pastebinCode.." downloads/"..name)
- if not fs.exists("downloads/"..name) then
- term.setTextColor(colors.red)
- print("Error retrieving module",name)
- print("Cancelling update")
- error()
- else
- term.setTextColor(colors.green)
- print("Successfully downloaded module",name)
- end
- end
- local function replaceModule(name)
- if not name or not fs.exists("downloads/"..name) then return end
- local x,y = term.getSize()
- for i=3,y do
- term.setCursorPos(1,i)
- term.clearLine()
- end
- term.setCursorPos(1,3)
- term.setTextColor(colors.yellow)
- if fs.exists(name) then
- print("Module",name,"already exists, removing it now")
- fs.delete(name)
- end
- fs.move("downloads/"..name,name)
- term.setTextColor(colors.green)
- print("Successfully replaced module",name)
- end
- for k,v in pairs(modules) do
- if not tonumber(moduleVersions[k]) or moduleVersions[k] < v[2] then
- downloadModule(v[1],k)
- end
- end
- for k,v in pairs(patterns) do
- downloadModule(v,"patterns/".. k ..".txt")
- end
- for k,v in pairs(modules) do
- moduleVersions[k] = v[2]
- replaceModule(k)
- end
- for k,v in pairs(patterns) do
- replaceModule("patterns/"..k .. ".txt")
- end
- if not os.getComputerLabel() then
- print("Fetching new label")
- local sectionChar = string.sub(utf8.char(167),2,2)
- local file = fs.open("names.json","r")
- local data = textutils.unserialiseJSON(file.readAll())
- file.close()
- local color = string.format("%x",math.random(0,15))
- os.setComputerLabel(sectionChar..color..data[math.random(#data)])
- end
- os.loadAPI("apis/stats.lua")
- stats.write("version",VERSION)
- moduleVersions["VERSION"] = VERSION
- if fs.exists("versions.json") then fs.delete("versions.json") end
- local file = fs.open("versions.json","w")
- file.write(textutils.serialiseJSON(moduleVersions))
- file.close()
- --local stats = require("statsAPI")
- --stats.write("version",VERSION)
Advertisement
Add Comment
Please, Sign In to add comment