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(61)
- mon = peripheral.wrap("monitor_8")
- red = colors.red
- yellow = colors.yellow
- green = colors.green
- black = colors.black
- white = colors.white
- orange = colors.orange
- term.redirect(mon)
- term.setBackgroundColor(black)
- term.clear()
- term.setCursorPos(1,1)
- mon9 = peripheral.wrap("monitor_9")
- acess = false
- sto = fs.open("DEFCON", "r")
- DEFCON = tonumber(sto.readLine())
- sto.close()
- 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(black)
- mon9.clear()
- mon9.setBackgroundColor(orange)
- mon9.setCursorPos(2,3)
- mon9.write("open")
- term.setBackgroundColor(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", orange)
- createButton(y1,yx1, x2, t1, "2", orange )
- createButton(y1, yx1, x3, t1, "3", orange)
- createButton(y2, yx2, x1, t1, "4", orange)
- createButton(y2, yx2, x2, t1, "5", orange)
- createButton(y2, yx2, x3, t1, "6", orange)
- createButton(y3, yx3, x1, t1, "7", orange)
- createButton(y3, yx3, x2, t1, "8", orange)
- createButton(y3, yx3, x3, t1, "9", orange)
- createButton(11, 13, 8, 5, "0", orange)
- end
- function click()
- event, side, m, d,k = os.pullEvent()
- term.setCursorPos(1,1)
- print(event)
- print(side)
- print(m)
- print(d)
- print(k)
- if event == "monitor_touch" then
- if side == "monitor_8" then
- data = compare(m,d)
- return (data)
- elseif side == "monitor_9" then
- redstone.setOutput("left",true)
- sleep(10)
- redstone.setOutput("left",false)
- end
- elseif event == "modem_message" then
- if m == 61 then
- if d == 62 then
- etat_porte = k
- elseif d == 63 then
- etat_lux = k
- elseif d == 64 then
- etat_energy = k
- elseif d == 65 then
- etat_securite = k
- elseif d == 66 then
- DEFCON = k
- h = fs.open("DEFCON", "w")
- h.write(DEFCON)
- h.close()
- elseif d == 67 then
- --cube2Max = k
- elseif d == 68 then
- --mfeMax = k
- elseif d == 69 then
- --mfe2Max = k
- end
- 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", red)
- elseif x < 12 and x > 8 and y < 4 and y > 1 then
- data = 2
- createButton(y1,yx1, x2, t1, "2", red)
- elseif x < 17 and x > 13 and y < 4 and y > 1 then
- data = 3
- createButton(y1, yx1, x3, t1, "3", red)
- elseif x < 7 and x > 3 and y < 7 and y > 4 then
- data = 4
- createButton(y2, yx2, x1, t1, "4", red)
- elseif x < 12 and x > 8 and y < 7 and y > 4 then
- data = 5
- createButton(y2, yx2, x2, t1, "5", red)
- elseif x < 17 and x > 13 and y < 7 and y > 4 then
- data = 6
- createButton(y2, yx2, x3, t1, "6", red)
- elseif x < 7 and x > 3 and y < 10 and y > 7 then
- data = 7
- createButton(y3, yx3, x1, t1, "7", red)
- elseif x < 12 and x > 8 and y < 10 and y > 7 then
- data = 8
- createButton(y3, yx3, x2, t1, "8", red)
- elseif x < 17 and x > 13 and y < 10 and y > 7 then
- data = 9
- createButton(y3, yx3, x3, t1, "9", red)
- elseif x < 13 and x > 7 and y < 13 and y > 10 then
- data = 0
- createButton(11, 13, 8, 5, "0", 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 and DEFCON >= 1 then
- acess = true
- elseif data1 == 1 and data2 == 4 and data3 == 1 and data4 == 8 and DEFCON >= 2 then
- acess = true
- elseif data1 == 3 and data2 == 9 and data3 == 4 and data4 == 5 and DEFCON >= 3 then
- acess = true
- elseif DEFCON == 4 then
- acess = true
- end
- end
- term.setBackgroundColor(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, red)
- sleep(10)
- term.clear()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement