Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getList()
- local list = {}
- local conts = ''
- local worked = false
- if http then
- worked = true
- local response = http.get("https://raw.githubusercontent.com/TheJogMan/JogProgs/master/progList")
- local str = response.readAll()
- conts = str
- local inItem = false
- local gotName = false
- local gotCode = false
- local gotID = false
- local gotVer = false
- local gotDesc = false
- local objStart = 0
- local curName = ''
- local curCode = ''
- local curID = ''
- local curVer = ''
- local curDesc = ''
- for i = 1, string.len(str) do
- local c = string.sub(str,i,i)
- if inItem == false then
- if c == '{' then
- inItem = true
- end
- else
- if c == '}' then
- inItem = false
- gotName = false
- gotCode = false
- gotID = false
- gotVer = false
- gotDesc = false
- curName = ''
- curCode = ''
- curID = ''
- curVer = ''
- curDesc = ''
- objStart = 0
- else
- if gotName == false then
- if objStart == 0 then
- if c == '[' then
- objStart = i + 1
- end
- else
- if c == ']' then
- local conv = string.sub(str,objStart,i - 1)
- local conv2 = ''
- for i = 1, string.len(conv) do
- local c = string.sub(conv,i,i)
- if c == '(' then
- local n = string.sub(conv,i + 1,i + 1)
- local r = ''
- if n == 1 then
- r = '('
- elseif n == 2 then
- r = ')'
- elseif n == 3 then
- r = '['
- elseif n == 4 then
- r = ']'
- elseif n == 5 then
- r = '{'
- elseif n == 6 then
- r = '}'
- end
- conv2 = conv2 .. r
- i = i + 2
- else
- conv2 = conv2 .. c
- end
- end
- curName = conv2
- gotName = true
- objStart = 0
- end
- end
- elseif gotCode == false then
- if objStart == 0 then
- if c == '[' then
- objStart = i + 1
- end
- else
- if c == ']' then
- local conv = string.sub(str,objStart,i - 1)
- local conv2 = ''
- for i = 1, string.len(conv) do
- local c = string.sub(conv,i,i)
- if c == '(' then
- local n = string.sub(conv,i + 1,i + 1)
- local r = ''
- if n == 1 then
- r = '('
- elseif n == 2 then
- r = ')'
- elseif n == 3 then
- r = '['
- elseif n == 4 then
- r = ']'
- elseif n == 5 then
- r = '{'
- elseif n == 6 then
- r = '}'
- end
- conv2 = conv2 .. r
- i = i + 2
- else
- conv2 = conv2 .. c
- end
- end
- curCode = conv2
- gotCode = true
- objStart = 0
- end
- end
- elseif gotID == false then
- if objStart == 0 then
- if c == '[' then
- objStart = i + 1
- end
- else
- if c == ']' then
- local conv = string.sub(str,objStart,i - 1)
- local conv2 = ''
- for i = 1, string.len(conv) do
- local c = string.sub(conv,i,i)
- if c == '(' then
- local n = string.sub(conv,i + 1,i + 1)
- local r = ''
- if n == 1 then
- r = '('
- elseif n == 2 then
- r = ')'
- elseif n == 3 then
- r = '['
- elseif n == 4 then
- r = ']'
- elseif n == 5 then
- r = '{'
- elseif n == 6 then
- r = '}'
- end
- conv2 = conv2 .. r
- i = i + 2
- else
- conv2 = conv2 .. c
- end
- end
- curID = conv2
- gotID = true
- objStart = 0
- end
- end
- elseif gotDesc == false then
- if objStart == 0 then
- if c == '[' then
- objStart = i + 1
- end
- else
- if c == ']' then
- local conv = string.sub(str,objStart,i - 1)
- local conv2 = ''
- for i = 1, string.len(conv) do
- local c = string.sub(conv,i,i)
- if c == '(' then
- local n = string.sub(conv,i + 1,i + 1)
- local r = ''
- if n == 1 then
- r = '('
- elseif n == 2 then
- r = ')'
- elseif n == 3 then
- r = '['
- elseif n == 4 then
- r = ']'
- elseif n == 5 then
- r = '{'
- elseif n == 6 then
- r = '}'
- end
- conv2 = conv2 .. r
- i = i + 2
- else
- conv2 = conv2 .. c
- end
- end
- curDesc = conv2
- gotDesc = true
- objStart = 0
- end
- end
- elseif gotVer == false then
- if objStart == 0 then
- if c == '[' then
- objStart = i + 1
- end
- else
- if c == ']' then
- local conv = string.sub(str,objStart,i - 1)
- local conv2 = ''
- for i = 1, string.len(conv) do
- local c = string.sub(conv,i,i)
- if c == '(' then
- local n = string.sub(conv,i + 1,i + 1)
- local r = ''
- if n == 1 then
- r = '('
- elseif n == 2 then
- r = ')'
- elseif n == 3 then
- r = '['
- elseif n == 4 then
- r = ']'
- elseif n == 5 then
- r = '{'
- elseif n == 6 then
- r = '}'
- end
- conv2 = conv2 .. r
- i = i + 2
- else
- conv2 = conv2 .. c
- end
- end
- curVer = conv2
- gotVer = true
- objStart = 0
- local obj = {}
- obj.name = curName
- obj.code = curCode
- obj.ID = curID
- obj.ver = curVer
- obj.desc = curDesc
- list[#list + 1] = obj
- end
- end
- end
- end
- end
- end
- response.close()
- end
- return list, conts, worked
- end
- function getListItem(id)
- local obj = nil
- local worked = false
- for i = 1, #list do
- local prog = list[i]
- if prog.ID == id then
- obj = prog
- i = #list
- end
- end
- return obj, worked
- end
- function convertInf2(inf)
- local nInf = ''
- for i = 1, string.len(inf) do
- local c = string.sub(inf,i,i)
- if c == '(' then
- nInf = nInf .. '(1)'
- elseif c == ')' then
- nInf = nInf .. '(2)'
- elseif c == '[' then
- nInf = nInf .. '(3)'
- elseif c == ']' then
- nInf = nInf .. '(4)'
- elseif c == '{' then
- nInf = nInf .. '(5)'
- elseif c == '}' then
- nInf = nInf .. '(6)'
- else
- nInf = nInf .. c
- end
- end
- return(nInf)
- end
- function saveChangeLog(clog)
- local str = '['.. convertInf2(clog.version) ..']['.. convertInf2(clog.label) ..']'
- for i = 1, #clog.changes do
- str = str .. '['.. convertInf2(clog.changes[i]) ..']'
- end
- local file = fs.open('disk/changeLog','w')
- file.write(str)
- file.close()
- end
- function getDiskSide(label)
- local peris = peripheral.getNames()
- local side = nil
- for i = 1, #peris do
- if peripheral.getType(peris[i]) == 'drive' then
- if disk.hasData(peris[i]) then
- if disk.getLabel(peris[i]) == label then
- side = peris[i]
- i = #peris
- end
- end
- end
- end
- return(side)
- end
- ------------------------------------------------------------------------------------------------------------------------------------------------------
- id = '2'
- ver = '1'
- list, conts, worked = getList()
- if worked then
- local prog, got = getListItem(id)
- if not prog.ver == ver then
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- print('Detected an update for the installation program')
- print('it will now be installed')
- shell.run('pastebin run '.. prog.code)
- print('rebooting')
- os.reboot()
- end
- end
- changeLog = {}
- changeLog.version = '1'
- changeLog.label = 'Initial Release!'
- changeLog.changes = {}
- ------------------------------------------------------------------------------------------------------------------------------------------------------
- changeLog.changes[#changeLog.changes + 1] = 'Initial Release!'
- ------------------------------------------------------------------------------------------------------------------------------------------------------
- saveChangeLog(changeLog)
- W, H = term.getSize()
- if W == 51 and H == 19 then
- shell.run('disk/computer/compMain')
- elseif W == 39 and H == 13 then
- shell.run('disk/turtle/turtleMain')
- elseif W == 1 and H == 1 then
- shell.run('disk/tablet/tabMain')
- else
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- print('This program is not able to run on this display')
- print('The disk will be ejected and the computer will reboot')
- sleep(2)
- end
- if getDiskSide('Jog Installer') then
- disk.eject(getDiskSide('Jog Installer'))
- end
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment