Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.setBackgroundColor(colors.cyan)
- term.clear()
- local inputname
- local inputcode
- function redrawlines()
- paintutils.drawLine(2,6,50,6,colors.lightGray)
- paintutils.drawLine(2,10,50,10,colors.lightGray)
- inputname = ''
- inputcode = ''
- end
- redrawlines()
- redrawlines()
- term.setBackgroundColor(colors.cyan)
- term.setCursorPos(3,5)
- write('Program Name')
- term.setCursorPos(3,9)
- write('Pastebin Code')
- term.setCursorPos(22,13)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.black)
- write('Install')
- term.setCursorPos(50,2)
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.black)
- write('X')
- local stop = false
- repeat
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.black)
- term.setCursorPos(22,13)
- write('Install')
- local _, m, x, y = os.pullEvent('mouse_click')
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.gray)
- if y == 6 then
- term.setCursorPos(2,6)
- inputname = read()
- elseif y == 10 then
- term.setCursorPos(2,10)
- inputcode = read()
- elseif y == 13 and x >= 22 and x <= 29 then
- if inputname == '' then
- term.setCursorPos(3,11)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.red)
- write('Please insert a file name!')
- elseif inputcode == '' then
- term.setCursorPos(3,11)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.red)
- write('Please insert a pastebin code!')
- else
- term.setCursorPos(1,11)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.lime)
- print('Installing Program...')
- if fs.exists('programs/'..inputname) then
- fs.delete('programs/'..inputname)
- end
- shell.run('pastebin get '..inputcode..' '..'programs/'..inputname)
- if fs.exists('programs/'..inputname) then
- local oldtext = {}
- local file = fs.open('programlist','r')
- repeat
- local text = file.readLine()
- if text ~= nil then
- table.insert(oldtext,text)
- end
- until text == nil
- file.close()
- local file = fs.open('programlist','w')
- for i,v in ipairs(oldtext) do
- file.writeLine(v)
- end
- local color1 = math.random(0,15)
- local color2 = math.random(0,14)
- if color2 >= color1 then
- color2 = color2 + 1
- end
- local count = #fs.list('programs/')
- local x = math.floor((count/7)+1)
- local y = count%7
- file.writeLine(x*2)
- file.writeLine(y*2)
- file.writeLine(2^color1)
- file.writeLine(2^color2)
- file.writeLine(string.byte(string.sub(inputname,1,1)))
- file.writeLine(inputname)
- end
- end
- sleep(2)
- term.setBackgroundColor(colors.cyan)
- paintutils.drawFilledBox(1,11,51,19,colors.cyan)
- redrawlines()
- elseif y == 2 and x == 50 then
- stop = true
- end
- until stop
Advertisement
Add Comment
Please, Sign In to add comment