daily pastebin goal
41%
SHARE
TWEET

test

a guest Jan 29th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local types = peripheral.getNames()
  2. local iPass = "6420"
  3. --ocal iPass = ""
  4. local mons = { }
  5. for _,m in pairs(types) do
  6.   if peripheral.getType(m) == 'monitor' then
  7.     table.insert(mons, peripheral.wrap(m))
  8.   end
  9. end
  10.  
  11. local floors = {
  12.   { name = 'Ndiniz ',  ri = 7 },
  13.   { name = 'Bedroom',  ri = 8 },
  14.   { name = 'Storage',  ri = 9 },
  15.   { name = 'Ground ',  ri = 6 },
  16.   { name = 'Smeltery', ri = 5 },
  17. }
  18.  
  19. local function clear(bg)
  20.   for _, monitor in pairs(mons) do
  21.      monitor.setBackgroundColor(bg)
  22.      monitor.setTextScale(.5)
  23.      monitor.clear()
  24.   end
  25. end
  26.  
  27. local function write(x, y, text, fg, bg)
  28.   for _, monitor in pairs(mons) do
  29.     monitor.setTextColor(fg)
  30.     monitor.setBackgroundColor(bg)
  31.     monitor.setCursorPos(x, y)
  32.     monitor.write(text)
  33.   end
  34. end
  35.  
  36. local function drawMenu()
  37.   for i, floor in ipairs(floors) do
  38.     write(5, i*2, floor.name, colors.white, colors.gray)
  39.   end
  40. end
  41.  
  42. local function drawKeypad()
  43.   write(5,1,"       ",colors.white,colors.gray)
  44.   write(5,2,"       ",colors.white,colors.gray)
  45.   ----------------------------------
  46.   write(6,2,"1",colors.white,colors.lightGray)
  47.   write(8,2,"2",colors.white,colors.lightGray)
  48.   write(10,2,"3",colors.white,colors.lightGray)
  49.   ----------------------------------
  50.   write(5,3,"       ",colors.white,colors.gray)
  51.   write(5,4,"       ",colors.white,colors.gray)
  52.   ----------------------------------
  53.   write(6,4,"4",colors.white,colors.lightGray)
  54.   write(8,4,"5",colors.white,colors.lightGray)
  55.   write(10,4,"6",colors.white,colors.lightGray)
  56.   ----------------------------------
  57.   write(5,5,"       ",colors.white,colors.gray)
  58.   write(5,6,"       ",colors.white,colors.gray)
  59.   ----------------------------------
  60.   write(6,6,"7",colors.white,colors.lightGray)
  61.   write(8,6,"8",colors.white,colors.lightGray)
  62.   write(10,6,"9",colors.white,colors.lightGray)
  63.   ----------------------------------
  64.   write(5,7,"       ",colors.white,colors.gray)
  65.   write(5,8,"       ",colors.white,colors.gray)
  66.   ----------------------------------
  67.   write(6,8,"C",colors.white,colors.lightGray)
  68.   write(8,8,"0",colors.white,colors.lightGray)
  69.   write(10,8,"E",colors.white,colors.lightGray)
  70.   ----------------------------------
  71.   write(5 ,9,"       ",colors.white,colors.gray)
  72.   write(5 ,10,"       ",colors.white,colors.gray)
  73. end
  74.  
  75. clear(colors.gray)
  76. drawMenu()
  77. local aa, ab, ac, ad = "", "", "", ""
  78. local pass = ''
  79. local setPEnter = 0
  80. local setP = 0
  81.  
  82. while true do
  83.   local event,button,X,Y = os.pullEvent()
  84.     if event == "monitor_touch" then
  85.       drawMenu()
  86.       drawKeypad()
  87.       -- you set setP to 0 here
  88. --      setP = 0
  89. --      local setPEnter = 0
  90.       -----------------------------------
  91. -- so it can only be 0 here
  92. if setP == 0 then
  93.       if X == 6 and Y == 2 then --1
  94.           pass = pass .. '1'
  95.         elseif X == 8 and Y == 2 then -- 2
  96.           pass = pass .. '2'
  97.         elseif X == 10 and Y == 2 then -- 3
  98.           pass = pass .. '3'
  99.         elseif X == 6 and Y == 4 then -- 4
  100.           pass = pass .. '4'
  101.         elseif X == 8 and Y == 4 then -- 5
  102.           pass = pass .. '5'
  103.         elseif X == 10 and Y == 4 then -- 6
  104.           pass = pass .. '6'
  105.         elseif X == 6 and Y == 6 then -- 7
  106.           pass = pass .. '7'
  107.         elseif X == 8 and Y == 6 then -- 8
  108.           pass = pass .. '8'
  109.         elseif X == 10 and Y == 6 then -- 9
  110.           pass = pass .. '9'
  111.         elseif X == 6 and Y == 8 then -- Clear
  112.           pass = ''
  113.         elseif X == 8 and Y == 8 then -- 0
  114.           pass = pass .. '0'
  115.         elseif X == 10 and Y == 8 then -- Enter
  116. print(pass)
  117. print(setP)
  118.           if iPass == pass then
  119.             setP = 1
  120.             drawMenu()
  121.           else
  122.             clear(colors.red)
  123.             os.sleep(.5)
  124.             clear(colors.gray)
  125.             drawKeypad()
  126.           end
  127.           pass = ''
  128.         end
  129.       else
  130. print('set p = 1')
  131. print('going to floor')
  132. setP = 0          
  133.             -----------------------------------
  134.             local floorNo = math.floor(Y / 2)
  135.             local floor = floors[floorNo]
  136.             if floor then
  137.               drawMenu()
  138.               write(5, floorNo * 2, floor.name, colors.lime, colors.gray)
  139.               local ri = 'redstone_integrator_' .. floor.ri
  140.               peripheral.call(ri, "setOutput", 'south', true)
  141.               os.sleep(.5)
  142.               peripheral.call(ri, "setOutput", 'south', false)
  143.             end
  144.             -----------------------------------
  145.         --end
  146.       end
  147.    end
  148.  print(pass)
  149.  
  150. end
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top