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
- local speaker = peripheral.find("speaker")
- 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
- rickroll()
- 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
- rickroll()
- 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
- rickroll()
- 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
- rickroll()
- 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
- rickroll()
- 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
- rickroll()
- 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
- rickroll()
- end
- function rickroll()
- speaker.playNote("flute", 0.5, 5)
- sleep(0.2)
- speaker.playNote("flute", 0.5, 7)
- sleep(0.2)
- speaker.playNote("flute", 0.5, 10)
- sleep(0.2)
- speaker.playNote("flute", 0.5, 7)
- sleep(0.2)
- speaker.playNote("flute", 0.5, 14)
- sleep(0.3)
- speaker.playNote("flute", 0.5, 14)
- sleep(0.3)
- speaker.playNote("flute", 0.5, 12)
- sleep(0.6)
- speaker.playNote("flute", 0.5, 5)
- sleep(0.2)
- speaker.playNote("flute", 0.5, 7)
- sleep(0.2)
- speaker.playNote("flute", 0.5, 10)
- sleep(0.2)
- speaker.playNote("flute", 0.5, 7)
- sleep(0.2)
- speaker.playNote("flute", 0.5, 12)
- sleep(0.3)
- speaker.playNote("flute", 0.5, 12)
- sleep(0.3)
- speaker.playNote("flute", 0.5, 10)
- sleep(0.1)
- speaker.playNote("flute", 0.5, 9)
- sleep(0.1)
- speaker.playNote("flute", 0.5, 7)
- 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, senderId, distance = {os.pullEvent()}
- if event[1] == "rednet_message" then
- if event[3] == "call0" then
- etage0()
- end
- if event[3] == "call10" then
- etage1()
- end
- if event[3] == "call20" then
- etage2()
- end
- if event[3] == "call30" then
- etage3()
- end
- if event[3] == "call40" then
- etage4()
- end
- if event[3] == "call50" then
- etage5()
- end
- if event[3] == "call60" then
- etage6()
- end
- elseif event[1] == "monitor_touch" then
- --Etage 1
- if y ~= 62 and event[3] >= startColumn[1] and event[3] < (startColumn[1] + width) and event[4] >= startRow[1] and event[4] < (startRow[1] + 1) then
- etage1()
- end
- --Etage 2
- if y ~= 52 and event[3] >= startColumn[1] and event[3] < (startColumn[1] + width) and event[4] >= startRow[2] and event[4] < (startRow[2] + 1) then
- etage2()
- end
- --Etage 3
- if y ~= 42 and event[3] >= startColumn[1] and event[3] < (startColumn[1] + width) and event[4] >= startRow[3] and event[4] < (startRow[3] + 1) then
- etage3()
- end
- --Etage 4
- if y ~= 32 and event[3] >= startColumn[3] and event[3] < (startColumn[3] + width) and event[4] >= startRow[1] and event[4] < (startRow[1] + 1) then
- etage4()
- end
- --Etage 5
- if y ~= 22 and event[3] >= startColumn[3] and event[3] < (startColumn[3] + width) and event[4] >= startRow[2] and event[4] < (startRow[2] + 1) then
- etage5()
- end
- --Etage 6
- if y ~= 12 and event[3] >= startColumn[3] and event[3] < (startColumn[3] + width) and event[4] >= startRow[3] and event[4] < (startRow[3] + 1) then
- etage6()
- end
- --Etage 0
- if y ~= 72 and event[3] >= startColumn[2] and event[3] < (startColumn[2] + width) and event[4] >= 1 and event[4] < (2) then
- etage0()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement