Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dir = "/"
- dirText = "X | Downloads"
- modemside = side
- color = colors.lightGray
- coloritems = colors.white
- textcolor = colors.black
- id = idnumber
- minnumber = 2
- maxnumber = 18
- minnum = 2
- maxnum = 18
- timeout = 0.5
- downloadList = {}
- rednet.open(modemside)
- fs.makeDir("Downloads")
- while true do
- function design()
- paint = paintutils.loadImage("FileDesign")
- paintutils.drawImage(paint,1,1)
- end
- term.clear()
- design()
- term.setTextColor(textcolor)
- term.setBackgroundColor(color)
- term.setCursorPos(9,1)
- term.write("| PC |")
- term.setCursorPos(36,1)
- term.write("| SERVER |")
- term.setCursorPos(1,1)
- term.write("v^")
- term.setCursorPos(29,1)
- term.write("v^")
- term.setCursorPos(51,19)
- term.write("$")
- term.setCursorPos(1,19)
- term.write(dirText)
- term.setBackgroundColor(colors.red)
- term.setCursorPos(51,1)
- term.write("X")
- term.setBackgroundColor(color)
- term.setCursorPos(1,1)
- function scrolldown()
- minnumber = minnumber + 1
- maxnumber = maxnumber + 1
- end
- function scrollup()
- minnumber = minnumber - 1
- maxnumber = maxnumber - 1
- end
- function scrolldowndownload()
- minnum = minnum + 1
- maxnum = maxnum + 1
- end
- function scrollupdownload()
- minnum = minnum - 1
- maxnum = maxnum - 1
- end
- function changeDir()
- if dir == "/" then
- dir = "Downloads/"
- dirText = "X | Hauptverzeichnis"
- else
- dir = "/"
- dirText = "X | Downloads "
- end
- end
- function createAuswahlUpload( ypos )
- if listedPrograms[ypos + minnumber - 2] then
- term.setBackgroundColor(color)
- term.setCursorPos(15,6)
- term.write(" ")
- term.setCursorPos(15,7)
- term.write(" ")
- term.setCursorPos(15,8)
- term.write(" ")
- term.setCursorPos(15,9)
- term.write(" ")
- term.setCursorPos(15,10)
- term.write(" ")
- term.setCursorPos(16,6)
- term.write("Name: ")
- term.write(listedPrograms[ypos + minnumber - 2])
- term.setBackgroundColor(coloritems)
- term.setCursorPos(16,7)
- term.write(" ")
- term.setCursorPos(16,8)
- term.write(" Speichern ")
- term.setCursorPos(16,9)
- term.write(" ")
- term.setBackgroundColor(coloritems)
- event, side, x, y = os.pullEvent("mouse_click")
- if x >= 16 and x <= 37 and y >= 7 and y <= 9 then
- program = fs.open(listedPrograms[ypos + minnumber - 2],"r")
- programdata = program.readAll()
- program.close()
- rednet.send(id,"U;"..listedPrograms[ypos + minnumber - 2].."$;"..programdata)
- a,b,c = rednet.receive(timeout)
- if a == nil then
- term.setBackgroundColor(color)
- term.setCursorPos(1,19)
- term.write("Keine Verbindung zum Server!")
- sleep(1)
- else
- term.setBackgroundColor(color)
- term.setCursorPos(1,19)
- term.write(b)
- sleep(1)
- end
- end
- end
- end
- function createAuswahlDownload( ypos )
- if downloadList[ypos + minnum - 2] then
- term.setBackgroundColor(color)
- term.setCursorPos(15,5)
- term.write(" ")
- term.setCursorPos(15,6)
- term.write(" ")
- term.setCursorPos(15,7)
- term.write(" ")
- term.setCursorPos(15,8)
- term.write(" ")
- term.setCursorPos(15,9)
- term.write(" ")
- term.setCursorPos(15,10)
- term.write(" ")
- term.setCursorPos(15,11)
- term.write(" ")
- term.setCursorPos(16,5)
- term.write("Name: ")
- term.write(downloadList[ypos + minnum - 2])
- term.setBackgroundColor(coloritems)
- term.setCursorPos(16,6)
- term.write(" ")
- term.setCursorPos(16,7)
- term.write(" Download ")
- term.setCursorPos(16,8)
- term.write(" ")
- term.setCursorPos(16,9)
- term.write(" Delete ")
- term.setCursorPos(16,10)
- term.write(" ")
- term.setBackgroundColor(color)
- event, side, x, y = os.pullEvent("mouse_click")
- if x >= 16 and x <= 37 and y == 7 then
- rednet.send(id,"D;"..downloadList[ypos + minnum - 2])
- a, b, c = rednet.receive(timeout)
- if a == nil then
- term.setBackgroundColor(color)
- term.setCursorPos(1,19)
- term.write("Keine Verbindung zum Server!")
- else
- if not fs.exists("Downloads/"..downloadList[ypos + minnum - 2]) then
- File = fs.open("Downloads/"..downloadList[ypos + minnum - 2],"w")
- File.write(b)
- File.close()
- term.setCursorPos(1,19)
- term.write("Erfolreich heruntergeladen")
- sleep(1)
- else
- term.setCursorPos(1,19)
- term.write("Datei existiert bereits!")
- sleep(1)
- end
- end
- elseif x >= 16 and x <= 37 and y == 9 then
- rednet.send(id,"B;"..downloadList[ypos + minnum - 2])
- a,b,c = rednet.receive(timeout)
- if a == nil then
- term.setBackgroundColor(color)
- term.setCursorPos(1,19)
- term.write("Keine Verbindung zum Server!")
- sleep(1)
- else
- term.setBackgroundColor(color)
- term.setCursorPos(1,19)
- term.write(b)
- sleep(1)
- end
- end
- end
- end
- -- Variablen
- ItemDownloadVisible = 2
- ItemDownloadInvisible = 2
- y = 2
- visible = 2
- invisible = 2
- items = ";"
- listedPrograms = {}
- -- Tabellen
- rednet.send(id,"L;")
- a, dL, c = rednet.receive(timeout)
- if a == nil then
- term.setBackgroundColor(coloritems)
- term.setCursorPos(32,2)
- term.write("Keine Verbindung")
- term.setCursorPos(32,3)
- term.write("zum Server!")
- else
- while string.find(dL,";") do
- findNew = string.find(dL.."",";")
- downloadList[ItemDownloadVisible] = string.sub(dL,1,findNew-1)
- dL = string.sub(dL,string.find(dL.."",";")+1)
- if ItemDownloadVisible >= minnum and ItemDownloadVisible <= maxnum then
- term.setBackgroundColor(coloritems)
- term.setCursorPos(32,ItemDownloadInvisible)
- term.write(downloadList[ItemDownloadVisible])
- ItemDownloadInvisible = ItemDownloadInvisible + 1
- end
- ItemDownloadVisible = ItemDownloadVisible + 1
- end
- end
- progs = fs.list(dir)
- for index, sItem in pairs(progs) do
- if fs.isDir(sItem)~=true then
- listedPrograms[visible] = sItem
- if visible >= minnumber and visible <= maxnumber then
- term.setBackgroundColor(coloritems)
- term.setCursorPos(3,invisible)
- term.write(listedPrograms[visible])
- invisible = invisible + 1
- end
- visible = visible + 1
- end
- end
- event, side, x, y = os.pullEvent()
- if event == "mouse_click" then
- if x > 3 and x < 25 and y > 1 and y < 19 then
- createAuswahlUpload(y)
- elseif x > 32 and x < 46 and y > 1 and y < 19 then
- createAuswahlDownload(y)
- elseif x == 51 and y == 1 then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- break
- elseif x == 51 and y == 19 then
- shell.run(shell.getRunningProgram())
- elseif x == 1 and y == 1 and maxnumber < visible-1 and minnumber < visible then
- scrolldown()
- elseif x == 2 and y == 1 and maxnumber > 18 and minnumber > 2 then
- scrollup()
- elseif x == 29 and y == 1 and maxnum < ItemDownloadVisible-1 and minnum < ItemDownloadVisible then
- scrolldowndownload()
- elseif x == 30 and y == 1 and maxnum > 18 and minnum > 2 then
- scrollupdownload()
- elseif x == 1 and y == 19 then
- changeDir()
- end
- elseif event == "mouse_scroll" then
- if side == 1 and maxnumber < visible - 1 and minnumber < visible then
- scrolldown()
- sleep(0.08)
- elseif side == -1 and maxnumber > 18 and minnumber > 2 then
- scrollup()
- sleep(0.08)
- elseif side == 1 and maxnum < ItemDownloadVisible-1 and minnum < ItemDownloadVisible then
- scrolldowndownload()
- sleep(0.08)
- elseif side == -1 and maxnum > 18 and minnum > 2 then
- scrollupdownload()
- sleep(0.08)
- end
- end
- end
- -- Scripted by Streetboy_xD
- -- Please keep this text in the program.
Advertisement
Add Comment
Please, Sign In to add comment