Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Archiv programm
- mon = peripheral.wrap("back")
- anzahl = 15
- playernames = {}
- scrollnumber = 1
- guiname="start"
- selected=""
- timertime=120
- colorcodes = {colors.white,colors.blue,colors.lime,colors.red,colors.brown,colors.yellow}
- function buttondraw(xp1,yp1,xp2,yp2,txt,col)
- if col==nil then
- mon.setBackgroundColor(colors.lime)
- else
- mon.setBackgroundColor(col)
- end
- mon.setCursorPos(xp1,yp1)
- for i=1,(xp2-xp1) do
- mon.write("-")
- end
- mon.setCursorPos(xp1,yp2)
- for i=1,(xp2-xp1) do
- mon.write("-")
- end
- for i=yp1,yp2 do
- mon.setCursorPos(xp1,i)
- mon.write("|")
- mon.setCursorPos(xp2,i)
- mon.write("|")
- end
- for i=(yp1+1),(yp2-1) do
- mon.setCursorPos((xp1+1),i)
- for j=(xp1+1),(xp2-1) do
- mon.write(" ")
- j = j+1
- end
- i = i+1
- end
- if math.floor(((xp2-xp1)-#txt)/2)==0 then
- xp1 = xp1+1
- end
- mon.setCursorPos(math.floor(((xp2-xp1)-#txt)/2)+xp1,math.floor((yp2-yp1)/2)+yp1)
- print(math.floor(((xp2-xp1)-#txt)/2))
- mon.write(txt)
- end
- function bdraw(xP,yP, str, ison)
- mon.setCursorPos(xP, yP)
- if ison then
- mon.setBackgroundColor(colors.lime)
- else
- mon.setBackgroundColor(colors.red)
- end
- for i=1,16 do
- mon.write(" ")
- end
- mon.setCursorPos(xP+((16-#str)/2),yP)
- mon.write(str)
- end
- function midwrite(txt, yP)
- x,y = mon.getSize()
- xP = (x-#txt)/2
- mon.setCursorPos(xP,yP)
- mon.write(txt)
- end
- function checkButtons(xPos, yPos)
- x,y = mon.getSize()
- if guiname=="start" then
- if xPos>=1 and xPos<=1
- and yPos>=3 and yPos<=4 then
- if scrollnumber>1 then
- scrollnumber = scrollnumber-1
- end
- end
- if xPos>=1 and xPos<=1
- and yPos>=y-3 and yPos<=y-2 then
- if scrollnumber+anzahl-1<24 and scrollnumber+anzahl-1<#playernames then
- scrollnumber = scrollnumber+1
- end
- end
- if xPos==x and yPos==1 then
- shutdown()
- end
- if yPos>=3 and yPos<=2+anzahl
- and xPos>=5 and xPos<=21 then
- selected = playernames[scrollnumber+yPos-3]
- end
- if xPos>=25 and xPos<=47
- and yPos>=5 and yPos<=9
- and selected=="" then
- add()
- end
- if xPos>=25 and xPos<=35
- and yPos>=13 and yPos<=17
- and selected~="" then
- guiname="turnoff"
- turnon(selected)
- end
- if xPos>=37 and xPos<=47
- and yPos>=13 and yPos<=17
- and selected~="" then
- --delete(selected)
- end
- end
- if guiname=="turnoff" then
- if xPos>=(x/2)-10 and xPos<=(x/2)+10
- and yPos>=(y/2)-4 and yPos<=(y/2)+4 then
- mon.setBackgroundColor(colors.gray)
- for j=5,y-4 do
- mon.setCursorPos(5,j)
- for k=5,x-4 do
- mon.write(" ")
- end
- end
- mon.setTextColor(colors.lightGray)
- midwrite("Es wird ausgeschaltet...",y-6)
- mon.setTextColor(colors.gray)
- for i=1,50 do
- pos = ((x-4-5-2)/100)*i
- mon.setCursorPos(6,y-5)
- mon.setBackgroundColor(colors.lime)
- for j=1,pos do
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.lightGray)
- mon.setBackgroundColor(colors.gray)
- midwrite(i.."%",y-5)
- if i==50 then
- debug(50)
- end
- sleep(0.01)
- end
- rs.setBundledOutput("right",0)
- rs.setBundledOutput("bottom",0)
- rs.setBundledOutput("left",0)
- rs.setBundledOutput("top",0)
- scrollnumber = 1
- guiname="start"
- selected=""
- end
- end
- end
- function drawInfo(ln1,ln2,ln3)
- ystart = math.floor((y-4)/2)
- mon.setTextColor(1)
- mon.setBackgroundColor(512)
- for i=ystart,ystart+4 do
- mon.setCursorPos(3,i)
- for j=3,x-3 do
- mon.write(" ")
- end
- end
- for i=ystart,ystart+4 do
- mon.setCursorPos(3,i)
- if i==ystart or i==ystart+4 then
- for j=3,x-3 do
- if j==3 or j==x-3 then
- mon.write("+")
- else
- mon.write("-")
- end
- end
- else
- mon.setCursorPos(3,i)
- mon.write("|")
- mon.setCursorPos(x-3,i)
- mon.write("|")
- end
- end
- xstart = math.floor(((x-6)-#ln1)/2)
- mon.setCursorPos(5+xstart,ystart+1)
- mon.write(ln1)
- xstart = math.floor(((x-6)-#ln2)/2)
- mon.setCursorPos(5+xstart,ystart+2)
- mon.write(ln2)
- xstart = math.floor(((x-6)-#ln3)/2)
- mon.setCursorPos(5+xstart,ystart+3)
- mon.write(ln3)
- end
- function logo()
- mon.setTextColor(colors.cyan)
- mon.setBackgroundColor(colors.gray)
- mon.setCursorPos((x-16)/2,1)
- mon.write("Jo")
- mon.setTextColor(colors.orange)
- mon.write("Ja")
- mon.setTextColor(colors.lightGray)
- mon.write(" Productions")
- end
- function gui()
- x,y = mon.getSize()
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.white)
- for i=1,y do
- mon.setCursorPos(1,i)
- for j=1,x do
- mon.write(" ")
- end
- end
- logo()
- loadData()
- if guiname=="start" then
- for i=scrollnumber,scrollnumber+anzahl-1 do
- if playernames[i]~=nil then
- isselected = false
- if playernames[i]==selected then
- isselected = true
- end
- bdraw(5,3+(i-scrollnumber),playernames[i],isselected)
- end
- end
- mon.setTextColor(colors.white)
- if scrollnumber>1 then
- mon.setBackgroundColor(colors.blue)
- else
- mon.setBackgroundColor(colors.gray)
- end
- mon.setCursorPos(1,3)
- mon.write("^")
- mon.setCursorPos(1,4)
- mon.write("|")
- if scrollnumber+anzahl-1<24 and scrollnumber+anzahl-1<#playernames then
- mon.setBackgroundColor(colors.blue)
- else
- mon.setBackgroundColor(colors.gray)
- end
- mon.setCursorPos(1,y-3)
- mon.write("|")
- mon.setCursorPos(1,y-2)
- mon.write("v")
- mon.setBackgroundColor(colors.red)
- mon.setTextColor(colors.white)
- mon.setCursorPos(x,1)
- mon.write("o")
- if selected=="" or selected==nil then
- buttondraw(25,5,47,9,"hinzufuegen",colors.orange)
- buttondraw(25,13,35,17,"aufrufen",colors.gray)
- buttondraw(37,13,47,17,"loeschen",colors.gray)
- else
- str = " Auswahl: "..selected.." "
- mon.setCursorPos(36-(#str/2),3)
- mon.setBackgroundColor(colors.gray)
- mon.setTextColor(colors.white)
- mon.write(str)
- buttondraw(25,5,47,9,"hinzufuegen",colors.gray)
- buttondraw(25,13,35,17,"aufrufen",colors.lime)
- buttondraw(37,13,47,17,"loeschen",colors.red)
- end
- end
- if guiname=="turnoff" then
- buttondraw((x/2)-10,(y/2)-4,(x/2)+10,(y/2)+4,"Ausschalten",colors.red)
- end
- end
- function debug(start)
- if start==nil then
- start=1
- else
- rs.setBundledOutput("right",65535)
- rs.setBundledOutput("bottom",65535)
- rs.setBundledOutput("left",65535)
- rs.setBundledOutput("top",65535)
- end
- mon.setBackgroundColor(colors.gray)
- for j=5,y-4 do
- mon.setCursorPos(5,j)
- for k=5,x-4 do
- mon.write(" ")
- end
- end
- mon.setTextColor(colors.lightGray)
- midwrite("Debug...",y-6)
- mon.setTextColor(colors.gray)
- for i=start,100 do
- pos = ((x-4-5-2)/100)*i
- mon.setCursorPos(6,y-5)
- mon.setBackgroundColor(colors.lime)
- for j=1,pos do
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.lightGray)
- mon.setBackgroundColor(colors.gray)
- midwrite(i.."%",y-5)
- sleep(0.01)
- if i==25 then
- rs.setBundledOutput("right",65535)
- rs.setBundledOutput("bottom",65535)
- rs.setBundledOutput("left",65535)
- rs.setBundledOutput("top",65535)
- end
- if i==75 then
- rs.setBundledOutput("right",0)
- rs.setBundledOutput("bottom",0)
- rs.setBundledOutput("left",0)
- rs.setBundledOutput("top",0)
- end
- end
- end
- function loadData()
- playernames = {}
- if not fs.exists("database.db") then
- file = fs.open("database.db","w")
- file.close()
- end
- file = fs.open("database.db","r")
- line = file.readLine()
- while line~=nil do
- playernames[#playernames+1] = line
- line = file.readLine()
- end
- file.close()
- end
- function add()
- rednet.open("front")
- rednet.send(10753,"Tastatur start")
- msgvorher=""
- success=false
- while success~=true do
- id,msg = rednet.receive()
- if msg=="Nachricht wurde uebermittelt" then
- success=true
- else
- msgvorher = msg
- end
- print(id.." "..msg)
- end
- rednet.close("front")
- file = fs.open("database.db","a")
- file.writeLine(msgvorher)
- print("Es wurde "..msgvorher.." geschrieben")
- file.close()
- loadData()
- gui()
- end
- function turnon(name)
- mon.setBackgroundColor(colors.gray)
- for j=5,y-4 do
- mon.setCursorPos(5,j)
- for k=5,x-4 do
- mon.write(" ")
- end
- end
- mon.setTextColor(colors.lightGray)
- midwrite("Es wird "..name.." aufgerufen",y-6)
- mon.setTextColor(colors.gray)
- for i=1,100 do
- pos = ((x-4-5-2)/100)*i
- mon.setCursorPos(6,y-5)
- mon.setBackgroundColor(colors.lime)
- for j=1,pos do
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.lightGray)
- mon.setBackgroundColor(colors.gray)
- midwrite(i.."%",y-5)
- sleep(0.01)
- end
- col=1
- num=0
- for i=1,#playernames do
- if playernames[i]==name then
- num = i
- color=col
- break
- end
- col = col+col
- end
- if num>=1 and num<=6 then
- side = "right"
- color = colorcodes[num]
- elseif num>=7 and num<=12 then
- side = "bottom"
- color = colorcodes[num-6]
- elseif num>=13 and num<=18 then
- side = "left"
- color = colorcodes[num-12]
- elseif num>=19 and num<=24 then
- side = "top"
- color = colorcodes[num-18]
- end
- rs.setBundledOutput(side,color)
- sleep(.5)
- end
- function shutdown()
- mon.setBackgroundColor(colors.gray)
- for j=5,y-4 do
- mon.setCursorPos(5,j)
- for k=5,x-4 do
- mon.write(" ")
- end
- end
- mon.setTextColor(colors.lightGray)
- midwrite("Ruhezustand starten...",y-6)
- mon.setTextColor(colors.gray)
- for i=1,50 do
- pos = ((x-4-5-2)/100)*i
- mon.setCursorPos(6,y-5)
- mon.setBackgroundColor(colors.lime)
- for j=1,pos do
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.lightGray)
- mon.setBackgroundColor(colors.gray)
- midwrite(i.."%",y-5)
- if i==50 then
- debug(50)
- end
- sleep(0.01)
- end
- os.reboot()
- end
- loadData()
- debug()
- timer = os.startTimer(timertime)
- gui()
- drawInfo("Bitte denke daran,","dass du nach 120 Sekunden","ausgeloggt wirst.")
- while true do
- event=""
- while event~="monitor_touch" do
- event,arg1,xPos,yPos = os.pullEvent()
- if event=="timer" and timer==arg1 then
- shutdown()
- end
- end
- checkButtons(xPos,yPos)
- loadData()
- gui()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement