SHOW:
|
|
- or go back to the newest paste.
| 1 | local programstemp = {}
| |
| 2 | local programs = {}
| |
| 3 | if not fs.exists('userdata/') then
| |
| 4 | fs.makeDir('userdata/')
| |
| 5 | end | |
| 6 | if not fs.exists('userdata/icon') then
| |
| 7 | local icon = fs.open('userdata/icon','w')
| |
| 8 | icon.writeLine('8877788')
| |
| 9 | icon.writeLine('8777778')
| |
| 10 | icon.writeLine('8777778')
| |
| 11 | icon.writeLine('8877788')
| |
| 12 | icon.writeLine('8777778')
| |
| 13 | icon.writeLine('7777777')
| |
| 14 | icon.close() | |
| 15 | end | |
| 16 | if not fs.exists('programs/') then
| |
| 17 | fs.makeDir('programs/')
| |
| 18 | shell.run('pastebin get zgMzYTPs programs/install')
| |
| 19 | end | |
| 20 | if not fs.exists('programlist') then
| |
| 21 | file = fs.open('/programlist','w')
| |
| 22 | file.writeLine('2.0')
| |
| 23 | file.writeLine('2.0')
| |
| 24 | file.writeLine('512.0')
| |
| 25 | file.writeLine('2048.0')
| |
| 26 | file.writeLine('25.0')
| |
| 27 | file.writeLine('install')
| |
| 28 | file.close() | |
| 29 | end | |
| 30 | ||
| 31 | local icon = paintutils.loadImage('userdata/icon')
| |
| 32 | local monitors = {peripheral.find('monitor')}
| |
| 33 | local newres = nil | |
| 34 | local monitoring = false | |
| 35 | local termog = term | |
| 36 | local ogmoresx, ogmoresy = term.getSize() | |
| 37 | if ogmoresx ~= 51 or ogmoresy ~= 19 then | |
| 38 | monitoring = true | |
| 39 | end | |
| 40 | if #monitors ~= 0 and monitoring == true then | |
| 41 | monitors[1].setTextScale(1) | |
| 42 | local omwidth, omheight = monitors[1].getSize() | |
| 43 | local omnwidth = omwidth/51 | |
| 44 | local omnheight = omheight/19 | |
| 45 | local newres = omnwidth | |
| 46 | if omnwidth > omnheight then | |
| 47 | newres = omnheight | |
| 48 | end | |
| 49 | if newres < 0.5 then | |
| 50 | newres = 0.5 | |
| 51 | error('Monitor too small!')
| |
| 52 | elseif newres > 5 then | |
| 53 | newres = 5 | |
| 54 | end | |
| 55 | monitors[1].setTextScale(newres) | |
| 56 | end | |
| 57 | term.setBackgroundColor(colors.lightGray) | |
| 58 | term.clear() | |
| 59 | local owidth, oheight = term.getSize() | |
| 60 | local newterm = window.create(term.current(),math.floor(owidth/2)-24,math.floor(oheight/2)-8,51,19,true) | |
| 61 | local owidth, oheight = term.getSize() | |
| 62 | local middlex = math.ceil(owidth/2) | |
| 63 | local middley = math.ceil(oheight/2) | |
| 64 | local posx, posy = newterm.getPosition() | |
| 65 | term.redirect(newterm) | |
| 66 | term.setBackgroundColor(colors.lightBlue) | |
| 67 | term.clear() | |
| 68 | paintutils.drawImage(icon,middlex-3,6) | |
| 69 | term.setCursorPos(middlex-3,14) | |
| 70 | term.setBackgroundColor(colors.lightGray) | |
| 71 | term.setTextColor(colors.gray) | |
| 72 | write('Sign In')
| |
| 73 | repeat | |
| 74 | _, m, x, y = os.pullEvent('mouse_click')
| |
| 75 | until x >= posx + 22 and x <= posx + 28 and y == posy + 13 | |
| 76 | local oldpull = os.pullEvent | |
| 77 | ||
| 78 | function newpull(event) | |
| 79 | if event ~= 'mouse_click' then | |
| 80 | return oldpull(event) | |
| 81 | elseif event == 'mouse_click' then | |
| 82 | local _, m, x, y = oldpull('mouse_click')
| |
| 83 | x = x - posx + 1 | |
| 84 | y = y - posy + 1 | |
| 85 | return _, m, x, y | |
| 86 | end | |
| 87 | end | |
| 88 | ||
| 89 | os.pullEvent = newpull | |
| 90 | ||
| 91 | term.setCursorPos(middlex-3,14) | |
| 92 | term.setBackgroundColor(colors.gray) | |
| 93 | term.setTextColor(colors.lightGray) | |
| 94 | write('Sign In')
| |
| 95 | sleep(0.3) | |
| 96 | while true do | |
| 97 | term.setBackgroundColor(colors.lightBlue) | |
| 98 | term.clear() | |
| 99 | programstemp = {}
| |
| 100 | programs = {}
| |
| 101 | local pfile = fs.open('programlist','r')
| |
| 102 | local timer = 0 | |
| 103 | ||
| 104 | repeat | |
| 105 | local line = pfile.readLine() | |
| 106 | if line ~= nil then | |
| 107 | table.insert(programstemp,line) | |
| 108 | end | |
| 109 | until line == nil | |
| 110 | ||
| 111 | for i,v in ipairs(programstemp) do | |
| 112 | timer = timer + 1 | |
| 113 | if timer%6 == 0 then | |
| 114 | table.insert(programs,{})
| |
| 115 | end | |
| 116 | end | |
| 117 | ||
| 118 | local index = 1 | |
| 119 | timer = 0 | |
| 120 | for i,v in ipairs(programstemp) do | |
| 121 | timer = timer + 1 | |
| 122 | local vt = v | |
| 123 | if timer%6 ~= 0 then | |
| 124 | vt = tonumber(v) | |
| 125 | end | |
| 126 | table.insert(programs[index],vt) | |
| 127 | if timer%6 == 0 then | |
| 128 | index = index + 1 | |
| 129 | end | |
| 130 | ||
| 131 | end | |
| 132 | paintutils.drawLine(1,19,51,19,colors.blue) | |
| 133 | for i,v in ipairs(programs) do | |
| 134 | term.setCursorPos(v[1],v[2]) | |
| 135 | term.setBackgroundColor(v[3]) | |
| 136 | term.setTextColor(v[4]) | |
| 137 | write(string.char(v[5])) | |
| 138 | end | |
| 139 | local clicked = false | |
| 140 | local clickeditem = '' | |
| 141 | repeat | |
| 142 | _, m, x, y = os.pullEvent('mouse_click')
| |
| 143 | for i,v in ipairs(programs) do | |
| 144 | if v[1] == x and v[2] == y then | |
| 145 | clicked = true | |
| 146 | clickeditem = v[6] | |
| 147 | end | |
| 148 | end | |
| 149 | until clicked | |
| 150 | term.setBackgroundColor(colors.black) | |
| 151 | term.setTextColor(colors.white) | |
| 152 | shell.run('/programs/'..clickeditem)
| |
| 153 | end |