Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Reaktorsteuerung
- local OPDInSide = "top"
- local monitorSide = "back"
- local bundledSide = "front"
- --bitte nichts mehr aendern
- local energy, breeder, st1, st2, st3 = 0
- local mon = peripheral.wrap(monitorSide)
- local x,y = mon.getSize()
- --useful functions
- function bdraw(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 sdraw(x1,y1,x2,y2,text,status,status2)
- if status then
- mon.setBackgroundColor(colors.lime)
- elseif status2 then
- mon.setBackgroundColor(colors.orange)
- else
- mon.setBackgroundColor(colors.red)
- end
- for i=y1,y2 do
- mon.setCursorPos(x1,i)
- for j=x1,x2 do
- mon.write(" ")
- end
- end
- if (x2-x1)<=#text then
- mon.setCursorPos(x1,math.floor((y2-y1)/2)+y1)
- else
- mon.setCursorPos(math.floor(((x2-x1)-#text)/2)+x1,math.floor((y2-y1)/2)+y1)
- end
- mon.setTextColor(colors.gray)
- mon.write(text)
- end
- --program
- function drawGUI()
- for i=1,y do
- mon.setCursorPos(1,i)
- mon.setBackgroundColor(colors.yellow)
- for j=1,x do
- mon.write(" ")
- end
- end
- mon.setTextColor(colors.gray)
- mon.setCursorPos(math.floor((x-21)/2),1)
- mon.write("Reaktor-Steuerung 2.0")
- local abstand = 1
- local breite = 6
- local pos1 = abstand
- local pos2 = abstand+breite
- sdraw(pos1,y-13,pos2,y-11,"Output",rs.testBundledInput(bundledSide,colors.green),false)
- local pos1 = pos1+abstand+breite+1
- local pos2 = pos2+abstand+breite+1
- sdraw(pos1,y-13,pos2,y-11,"Breeder",rs.testBundledInput(bundledSide,colors.blue),rs.testBundledInput(bundledSide,colors.lightGray))
- local pos1 = pos1+abstand+breite
- local pos2 = pos2+abstand+breite
- sdraw(pos1,y-13,pos2,y-11,"Stufe 1",rs.testBundledInput(bundledSide,colors.yellow))
- local pos1 = pos1+abstand+breite
- local pos2 = pos2+abstand+breite
- sdraw(pos1,y-13,pos2,y-11,"Stufe 2",rs.testBundledInput(bundledSide,colors.orange))
- local pos1 = pos1+abstand+breite
- local pos2 = pos2+abstand+breite
- sdraw(pos1,y-13,pos2,y-11,"Stufe 3",rs.testBundledInput(bundledSide,colors.red))
- local pos1 = pos1+abstand+breite
- local pos2 = pos2+abstand+breite
- sdraw(pos1,y-13,pos2,y-11,"Stufe 4",rs.testBundledInput(bundledSide,colors.purple))
- local pos1 = pos1+abstand+breite
- local pos2 = pos2+abstand+breite
- sdraw(pos1,y-13,pos2,y-11,"AUTO",rs.testBundledInput(bundledSide,colors.magenta),true)
- bdraw(2,y-7,18,y-5,"Reaktorstufe +1",colors.lightGreen)
- bdraw(2,y-3,18,y-1,"Reaktorstufe -4",colors.red)
- bdraw(x-19,y-7,x-1,y-5,"Breeder",colors.cyan)
- bdraw(x-19,y-3,x-1,y-1,"Update",colors.lightGray)
- end
- function checkButtons(xPos, yPos)
- if not event=="monitor_touch" then
- print("other event")
- return
- end
- if xPos>=2 and xPos<=18 and yPos>=y-7 and yPos<=y-5 then
- rs.setBundledOutput("front",rs.getBundledOutput("front")+colors.pink)
- bdraw(2,y-7,18,y-5,"Reaktorstufe +1",colors.green)
- sleep(0.25)
- rs.setBundledOutput("front",rs.getBundledOutput("front")-colors.pink)
- end
- if xPos>=2 and xPos<=18 and yPos>=y-3 and yPos<=y-1 then
- rs.setBundledOutput("front",rs.getBundledOutput("front")+colors.cyan)
- bdraw(2,y-3,18,y-1,"Reaktorstufe -4",colors.magenta)
- sleep(0.25)
- rs.setBundledOutput("front",rs.getBundledOutput("front")-colors.cyan)
- end
- if xPos>=x-19 and xPos<=x-1 and yPos>=y-7 and yPos<=y-5 then
- rs.setBundledOutput("front",rs.getBundledOutput("front")+colors.gray)
- bdraw(x-19,y-7,x-1,y-5,"Breeder",colors.blue)
- sleep(0.25)
- rs.setBundledOutput("front",rs.getBundledOutput("front")-colors.gray)
- end
- if xPos>=x-19 and xPos<=x-1 and yPos>=y-3 and yPos<=y-1 then
- bdraw(x-19,y-3,x-1,y-1,"Update",colors.gray)
- sleep(0.25)
- os.reboot()
- end
- end
- --main program
- while true do
- drawGUI()
- event, side, xPos, yPos = os.pullEvent()
- if event=="monitor_touch" then
- checkButtons(xPos, yPos)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement