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
- function etage0()
- if y == 62 then
- rednet.send(turtleID, "button062")
- elseif y == 52 then
- rednet.send(turtleID, "button052")
- elseif y == 42 then
- rednet.send(turtleID, "button042")
- elseif y == 32 then
- rednet.send(turtleID, "button032")
- elseif y == 22 then
- rednet.send(turtleID, "button022")
- elseif y == 12 then
- rednet.send(turtleID, "button012")
- end
- end
- function etage1()
- if y == 72 then
- rednet.send(turtleID, "button172")
- elseif y == 52 then
- rednet.send(turtleID, "button152")
- elseif y == 42 then
- rednet.send(turtleID, "button142")
- elseif y == 32 then
- rednet.send(turtleID, "button132")
- elseif y == 22 then
- rednet.send(turtleID, "button122")
- elseif y == 12 then
- rednet.send(turtleID, "button112")
- end
- end
- function etage2()
- if y == 72 then
- rednet.send(turtleID, "button272")
- elseif y == 62 then
- rednet.send(turtleID, "button262")
- elseif y == 42 then
- rednet.send(turtleID, "button242")
- elseif y == 32 then
- rednet.send(turtleID, "button232")
- elseif y == 22 then
- rednet.send(turtleID, "button222")
- elseif y == 12 then
- rednet.send(turtleID, "button212")
- end
- end
- function etage3()
- if y == 72 then
- rednet.send(turtleID, "button372")
- elseif y == 62 then
- rednet.send(turtleID, "button362")
- elseif y == 52 then
- rednet.send(turtleID, "button352")
- elseif y == 32 then
- rednet.send(turtleID, "button332")
- elseif y == 22 then
- rednet.send(turtleID, "button322")
- elseif y == 12 then
- rednet.send(turtleID, "button312")
- end
- end
- function etage4()
- if y == 72 then
- rednet.send(turtleID, "button472")
- elseif y == 62 then
- rednet.send(turtleID, "button462")
- elseif y == 52 then
- rednet.send(turtleID, "button452")
- elseif y == 42 then
- rednet.send(turtleID, "button442")
- elseif y == 22 then
- rednet.send(turtleID, "button422")
- elseif y == 12 then
- rednet.send(turtleID, "button412")
- end
- end
- function etage5()
- if y == 72 then
- rednet.send(turtleID, "button572")
- elseif y == 62 then
- rednet.send(turtleID, "button562")
- elseif y == 52 then
- rednet.send(turtleID, "button552")
- elseif y == 42 then
- rednet.send(turtleID, "button542")
- elseif y == 32 then
- rednet.send(turtleID, "button532")
- elseif y == 12 then
- rednet.send(turtleID, "button512")
- end
- end
- function etage6()
- if y == 72 then
- rednet.send(turtleID, "button672")
- elseif y == 62 then
- rednet.send(turtleID, "button662")
- elseif y == 52 then
- rednet.send(turtleID, "button652")
- elseif y == 42 then
- rednet.send(turtleID, "button642")
- elseif y == 32 then
- rednet.send(turtleID, "button632")
- elseif y == 22 then
- rednet.send(turtleID, "button622")
- end
- 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, message = os.pullEvent()
- if event == "rednet_message" then
- if message == "call0" then
- etage0()
- end
- if message == "call10" then
- etage1()
- end
- if message == "call20" then
- etage2()
- end
- if message == "call30" then
- etage3()
- end
- if message == "call40" then
- etage4()
- end
- if message == "call50" then
- etage5()
- end
- if message == "call60" then
- etage6()
- end
- end
- if event == "monitor_touch" then
- --Etage 1
- if y ~= 62 and cx >= startColumn[1] and cx < (startColumn[1] + width) and cy >= startRow[1] and cy < (startRow[1] + 1) then
- etage1()
- end
- --Etage 2
- if y ~= 52 and cx >= startColumn[1] and cx < (startColumn[1] + width) and cy >= startRow[2] and cy < (startRow[2] + 1) then
- etage2()
- end
- --Etage 3
- if y ~= 42 and cx >= startColumn[1] and cx < (startColumn[1] + width) and cy >= startRow[3] and cy < (startRow[3] + 1) then
- etage3()
- end
- --Etage 4
- if y ~= 32 and cx >= startColumn[3] and cx < (startColumn[3] + width) and cy >= startRow[1] and cy < (startRow[1] + 1) then
- etage4()
- end
- --Etage 5
- if y ~= 22 and cx >= startColumn[3] and cx < (startColumn[3] + width) and cy >= startRow[2] and cy < (startRow[2] + 1) then
- etage5()
- end
- --Etage 6
- if y ~= 12 and cx >= startColumn[3] and cx < (startColumn[3] + width) and cy >= startRow[3] and cy < (startRow[3] + 1) then
- etage6()
- end
- --Etage 0
- if y ~= 72 and cx >= startColumn[2] and cx < (startColumn[2] + width) and cy >= 1 and cy < (2) then
- etage0()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement