Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- peripheral.find("modem",rednet.open)
- local monitor = peripheral.find("monitor")
- peripheral.wrap("monitor")
- monitor.setTextScale(1)
- monitor.clear()
- local defaultBackgroundColor = colors.black
- local defaultTextColor = colors.white
- local backgroundColorNormal = colors.blue
- local backgroundColorPressed = colors.red
- local textColorNormal = colors.white
- local textColorPressed = colors.yellow
- local width = 3
- local height = 1.75
- local startColumn = {2,6,9}
- local startRow = {3,5,7, 3,5,7}
- local row = 2
- local column = 2
- local tlabel = {"1","2","3","4","5","6"}
- local label = "1"
- local label0 = "0"
- local x, y, z = gps.locate(5)
- local turtleID = 23
- function resetScreen()
- monitor.setBackgroundColor(defaultBackgroundColor)
- monitor.setTextColor(defaultTextColor)
- end
- --init
- function init()
- resetScreen()
- monitor.setTextScale(1.5)
- monitor.clear()
- end
- --button background
- function displayButtonBackground()
- monitor.setBackgroundColor(backgroundColorNormal)
- for roww = row, row + height - 1 do
- monitor.setCursorPos(column, row)
- monitor.write(string.rep(" ", width))
- end
- end
- --display label
- function displayLabel()
- monitor.setTextColor(textColorNormal)
- displayButtonBackground()
- monitor.setCursorPos(column + math.floor((width - #label)/2), row + math.floor(height/2))
- monitor.write(label)
- end
- function displayLabel0()
- monitor.setTextColor(textColorNormal)
- monitor.setCursorPos(6, 1)
- monitor.setBackgroundColor(backgroundColorNormal)
- monitor.write(string.rep(" ", width))
- monitor.setCursorPos(6 + math.floor((width - #label0)/2), 1 + math.floor(height/2))
- monitor.write(label0)
- end
- init()
- for i = 1, 3, 1 do
- column = startColumn[1]
- row = startRow[i]
- label = tlabel[i]
- displayLabel()
- end
- for i = 4, 6, 1 do
- column = startColumn[3]
- row = startRow[i]
- label = tlabel[i]
- displayLabel()
- end
- displayLabel0()
- while (1) do
- local event, button, cx, cy = os.pullEvent("monitor_touch")
- if event == "monitor_touch" then
- --Etage 1
- if cx >= startColumn[1] and cx < (startColumn[1] + width) and cy >= startRow[1] and cy < (startRow[1] + 1) then
- rednet.send(turtleID, "button1")
- end
- --Etage 2
- if cx >= startColumn[1] and cx < (startColumn[1] + width) and cy >= startRow[2] and cy < (startRow[2] + 1) then
- rednet.send(turtleID, "button2")
- end
- --Etage 3
- if cx >= startColumn[1] and cx < (startColumn[1] + width) and cy >= startRow[3] and cy < (startRow[3] + 1) then
- rednet.send(turtleID, "button3")
- end
- --Etage 4
- if cx >= startColumn[3] and cx < (startColumn[3] + width) and cy >= startRow[1] and cy < (startRow[1] + 1) then
- rednet.send(turtleID, "button4")
- end
- --Etage 5
- if cx >= startColumn[3] and cx < (startColumn[3] + width) and cy >= startRow[2] and cy < (startRow[2] + 1) then
- rednet.send(turtleID, "button5")
- end
- --Etage 6
- if cx >= startColumn[3] and cx < (startColumn[3] + width) and cy >= startRow[3] and cy < (startRow[3] + 1) then
- rednet.send(turtleID, "button6")
- end
- --Etage 0
- if y < 72 and cx >= startColumn[2] and cx < (startColumn[2] + width) and cy >= 1 and cy < (2) then
- if y == 62 then
- rednet.send(turtleID, "button062")
- elseif y == 52 then
- rednet.send(turtleID, "button052")
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement