Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not fs.exists('userdata/') then
- fs.makeDir('userdata/')
- end
- if not fs.exists('userdata/icon') then
- local icon = fs.open('userdata/icon','w')
- icon.writeLine('8877788')
- icon.writeLine('8777778')
- icon.writeLine('8777778')
- icon.writeLine('8877788')
- icon.writeLine('8777778')
- icon.writeLine('7777777')
- icon.close()
- end
- if not fs.exists('programs/') then
- fs.makeDir('programs/')
- shell.run('pastebin get zgMzYTPs programs/install')
- end
- if not fs.exists('programlist') then
- file = fs.open('/programlist','w')
- file.writeLine('2.0')
- file.writeLine('2.0')
- file.writeLine('512.0')
- file.writeLine('2048.0')
- file.writeLine('25.0')
- file.writeLine('install')
- file.close()
- end
- local programstemp = {}
- local programs = {}
- local pfile = fs.open('programlist','r')
- local timer = 0
- repeat
- local line = pfile.readLine()
- if line ~= nil then
- table.insert(programstemp,line)
- end
- until line == nil
- for i,v in ipairs(programstemp) do
- timer = timer + 1
- if timer%6 == 0 then
- table.insert(programs,{})
- end
- end
- local index = 1
- timer = 0
- for i,v in ipairs(programstemp) do
- timer = timer + 1
- local vt = v
- if timer%6 ~= 0 then
- vt = tonumber(v)
- end
- table.insert(programs[index],vt)
- if timer%6 == 0 then
- index = index + 1
- end
- end
- local icon = paintutils.loadImage('userdata/icon')
- local monitors = {peripheral.find('monitor')}
- local newres = nil
- local monitoring = false
- local termog = term
- local ogmoresx, ogmoresy = term.getSize()
- if ogmoresx ~= 51 or ogmoresy ~= 19 then
- monitoring = true
- end
- if #monitors ~= 0 and monitoring == true then
- monitors[1].setTextScale(1)
- local omwidth, omheight = monitors[1].getSize()
- local omnwidth = omwidth/51
- local omnheight = omheight/19
- local newres = omnwidth
- if omnwidth > omnheight then
- newres = omnheight
- end
- if newres < 0.5 then
- newres = 0.5
- error('Monitor too small!')
- elseif newres > 5 then
- newres = 5
- end
- monitors[1].setTextScale(newres)
- end
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- local owidth, oheight = term.getSize()
- local newterm = window.create(term.current(),math.floor(owidth/2)-24,math.floor(oheight/2)-8,51,19,true)
- local owidth, oheight = term.getSize()
- local middlex = math.ceil(owidth/2)
- local middley = math.ceil(oheight/2)
- local posx, posy = newterm.getPosition()
- term.redirect(newterm)
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- paintutils.drawImage(icon,middlex-3,6)
- term.setCursorPos(middlex-3,14)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.gray)
- write('Sign In')
- repeat
- _, m, x, y = os.pullEvent('mouse_click')
- until x >= posx + 22 and x <= posx + 28 and y == posy + 13
- local oldpull = os.pullEvent
- function newpull(event)
- if event ~= 'mouse_click' then
- return oldpull(event)
- elseif event == 'mouse_click' then
- local _, m, x, y = oldpull('mouse_click')
- x = x - posx + 1
- y = y - posy + 1
- return _, m, x, y
- end
- end
- os.pullEvent = newpull
- term.setCursorPos(middlex-3,14)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.lightGray)
- write('Sign In')
- sleep(0.3)
- while true do
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- paintutils.drawLine(1,19,51,19,colors.blue)
- for i,v in ipairs(programs) do
- term.setCursorPos(v[1],v[2])
- term.setBackgroundColor(v[3])
- term.setTextColor(v[4])
- write(string.char(v[5]))
- end
- local clicked = false
- local clickeditem = ''
- repeat
- _, m, x, y = os.pullEvent('mouse_click')
- for i,v in ipairs(programs) do
- if v[1] == x and v[2] == y then
- clicked = true
- clickeditem = v[6]
- end
- end
- until clicked
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- shell.run('/programs/'..clickeditem)
- end
Advertisement
Add Comment
Please, Sign In to add comment