Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monSide = "top"
- local bunSide = "back"
- local m = peripheral.wrap(monSide)
- local xMax,yMax = m.getSize()
- --xStart,yStart,xEnd,yEnd,txt,displayColor,cableColor,stat
- local button = {}
- button[1] = {37,16,53,20,_,_,colors.white}
- function drawField(xStart,yStart,xEnd,yEnd,col)
- m.setBackgroundColor(col)
- for yP = yStart,yEnd do
- m.setCursorPos(xStart,yP)
- for xP = xStart,xEnd do
- m.write(" ")
- end
- end
- end
- function drawButton(arr)
- for i = 1,#arr do
- drawField(arr[i][1],arr[i][2],arr[i][3],arr[i][4],arr[i][6])
- m.setCursorPos(arr[i][1]+.5+((arr[i][3]-arr[i][1])/2-#arr[i][5]/2),arr[i][2]+(arr[i][4]-arr[i][2])/2)
- m.write(arr[i][5])
- end
- end
- function checkButton(arr,xP,yP)
- for i = 1,#arr do
- if xP >= arr[i][1] and xP <= arr[i][3] and yP >= arr[i][2] and yP <= arr[i][4] then
- if arr[i][8] then
- arr[i][8] = false
- else
- arr[i][8] = true
- end
- return i
- end
- end
- end
- while true do
- button[1][8] = colors.test(rs.getBundledInput(bunSide),colors.white)
- if button[1][8] then
- button[1][5] = "Reaktor stoppen"
- button[1][6] = colors.red
- else
- button[1][5] = "Reaktor starten"
- button[1][6] = colors.lime
- end
- drawButton(button)
- local event,_,xP,yP = os.pullEvent("monitor_touch")
- if checkButton(button,xP,yP) == 1 then
- rs.setBundledOutput(bunSide,colors.gray)
- sleep(.5)
- rs.setBundledOutput(bunSide,0)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment