Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- redstone.setOutput("left",false)
- modem = peripheral.wrap("right")
- modem.open(56)
- mon = peripheral.wrap("monitor_8")
- term.redirect(mon)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- mon9 = peripheral.wrap("monitor_9")
- acess = false
- function createBox (name, xmin, xmax, ymin, ymax, text, color)
- currentY = ymin
- while currentY ~= ymax do
- term.setCursorPos(xmin, currentY)
- for i = 1, xmax do
- write(" ")
- end
- currentY = currentY + 1
- end
- end
- function createButton (ymin, ymax, xmin, xmax, text, color)
- term.setBackgroundColor(color)
- xLoc = xmin + (math.ceil((xmax - string.len(text))/2))
- yLoc = math.ceil((ymax + ymin)/2)-1
- createBox(name, xmin, xmax, ymin, ymax, text, color)
- term.setCursorPos(xLoc,yLoc)
- write(text)
- end
- function digi()
- mon9.setBackgroundColor(colors.black)
- mon9.clear()
- mon9.setBackgroundColor(colors.orange)
- mon9.setCursorPos(2,3)
- mon9.write("open")
- term.setBackgroundColor(colors.black)
- term.clear()
- x1 = 4
- x2 = 9
- x3 = 14
- t1 = 3
- y1 = 2
- y2 = 5
- y3 = 8
- yx1 = y1+2
- yx2 = y2+2
- yx3 = y3+2
- createButton(y1,yx1 , x1, t1, "1", colors.orange )
- createButton(y1,yx1, x2, t1, "2", colors.orange )
- createButton(y1, yx1, x3, t1, "3", colors.orange )
- createButton(y2, yx2, x1, t1, "4", colors.orange )
- createButton(y2, yx2, x2, t1, "5", colors.orange )
- createButton(y2, yx2, x3, t1, "6", colors.orange )
- createButton(y3, yx3, x1, t1, "7", colors.orange )
- createButton(y3, yx3, x2, t1, "8", colors.orange )
- createButton(y3, yx3, x3, t1, "9", colors.orange )
- createButton(11, 13, 8, 5, "0", colors.orange )
- end
- function click()
- event, side, x, y = os.pullEvent("monitor_touch")
- if side == "monitor_8" then
- data = compare(x,y)
- return (data)
- elseif side == "monitor_9" then
- redstone.setOutput("left",true)
- sleep(10)
- redstone.setOutput("left",false)
- end
- --end
- end
- function compare(x,y)
- x1 = 4
- x2 = 9
- x3 = 14
- t1 = 3
- y1 = 2
- y2 = 5
- y3 = 8
- yx1 = y1+2
- yx2 = y2+2
- yx3 = y3+2
- data = 0
- if x < 7 and x > 3 and y < 4 and y > 1 then
- data = 1
- createButton(y1,yx1 , x1, t1, "1", colors.red)
- elseif x < 12 and x > 8 and y < 4 and y > 1 then
- data = 2
- createButton(y1,yx1, x2, t1, "2", colors.red)
- elseif x < 17 and x > 13 and y < 4 and y > 1 then
- data = 3
- createButton(y1, yx1, x3, t1, "3", colors.red)
- elseif x < 7 and x > 3 and y < 7 and y > 4 then
- data = 4
- createButton(y2, yx2, x1, t1, "4", colors.red)
- elseif x < 12 and x > 8 and y < 7 and y > 4 then
- data = 5
- createButton(y2, yx2, x2, t1, "5", colors.red)
- elseif x < 17 and x > 13 and y < 7 and y > 4 then
- data = 6
- createButton(y2, yx2, x3, t1, "6", colors.red)
- elseif x < 7 and x > 3 and y < 10 and y > 7 then
- data = 7
- createButton(y3, yx3, x1, t1, "7", colors.red)
- elseif x < 12 and x > 8 and y < 10 and y > 7 then
- data = 8
- createButton(y3, yx3, x2, t1, "8", colors.red)
- elseif x < 17 and x > 13 and y < 10 and y > 7 then
- data = 9
- createButton(y3, yx3, x3, t1, "9", colors.red)
- elseif x < 13 and x > 7 and y < 13 and y > 10 then
- data = 0
- createButton(11, 13, 8, 5, "0", colors.red)
- else
- data = nil
- end
- if data ~= nil then
- sleep(1)
- return (data)
- end
- end
- while (true) do
- if acess == true then
- --id,msg,dis = rednet.receive()
- redstone.setOutput("left", false)
- acess = false
- end
- digi()
- acess = false
- data1, data2, data3, data4 = nil
- while (acess == false) do
- digi()
- data = click()
- if data1 == nil then
- data1 = data
- elseif data2 == nil then
- data2 = data
- elseif data3 == nil then
- data3 = data
- elseif data4 == nil then
- data4 = data
- else
- data1 = data2
- data2 = data3
- data3 = data4
- data4 = data
- end
- if data1 == 2 and data2 == 0 and data3 == 1 and data4 == 2 then
- acess = true
- end
- end
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- if acess == true then
- resultat = "bienvenue ! ^^"
- modem.transmit(56,56,"ouverture")
- redstone.setOutput("left",true)
- --rednet.send (56,msg)
- createButton(4, 7, 3, 15, resultat, colors.red)
- sleep(10)
- term.clear()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement