Advertisement
_DeNiS_On4Ik_

image

Feb 6th, 2021 (edited)
560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.39 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. sleep(0.1)
  3. shell.switchTab(2)
  4.  
  5.  
  6. m = peripheral.wrap("top")
  7. m.clear()
  8. m.setTextScale(1.5)
  9. m.setBackgroundColor(colors.black)
  10. m.setTextColor(colors.white)
  11.  
  12. inp = {}
  13. sPos = 4
  14.  
  15.  
  16. function mGUI()
  17.     gui = {
  18.         [[ wo  (5x4)           ]],
  19.         [[                     ]],
  20.         [[                     ]],
  21.         [[                     ]],
  22.         [[                     ]],
  23.         [[                     ]],
  24.         [[                     ]],
  25.         [[                     ]],
  26.         [[                     ]],
  27.         [[                     ]],
  28.         }
  29.     m.setTextColor(colors.white)
  30.     for i = 1,10 do
  31.         m.setCursorPos(1,i)
  32.         if i == 3 then
  33.             m.setTextColor(colors.white)
  34.         end
  35.         m.write(gui[i])
  36.     end
  37.  m.setCursorPos(2,1)
  38.  m.setBackgroundColor(colors.lime)
  39.  m.setTextColor(colors.white)
  40.  m.write("wo")
  41. end
  42.  
  43. function open()
  44.     if autoReset then
  45.         if waitTime == 0 then waitTime = 2 end
  46.         sleep(waitTime)
  47.         rs.setOutput(redstoneSide,false)
  48.         os.reboot()
  49.     else
  50.         m.setBackgroundColor(colors.black)
  51.         m.clear()
  52.         m.setTextScale(5)
  53.         m.setCursorPos(1,1)
  54.         m.write("<")
  55.         ev, side, xPos, yPos = os.pullEvent("monitor_touch")
  56.         rs.setOutput(redstoneSide,false)
  57.         os.reboot()
  58.     end
  59. end
  60.  
  61. function checkInp()
  62.     if #inp == #code then
  63.         for f = 1,#code do
  64.             if inp[f] == code[f] then
  65.                 if f == #code then
  66.                     m.setCursorPos(3,4)
  67.                     m.setBackgroundColor(colors.lime)
  68.                     m.write(" CORRECT!  ")
  69.                     rs.setOutput(redstoneSide,true)
  70.                     open()
  71.  
  72.                 end
  73.             else
  74.                 m.setCursorPos(3,4)
  75.                 m.setBackgroundColor(colors.red)
  76.                 m.write("WRONG CODE!")
  77.     shell.run("test")
  78.                 sleep(3)
  79.                 os.reboot()
  80.             end
  81.         end
  82.     else
  83.         m.setCursorPos(3,4)
  84.         m.setBackgroundColor(colors.red)
  85.         m.write("WRONG CODE!")
  86.      shell.run("test")
  87.     sleep(3)
  88.         os.reboot()
  89.     end
  90. end
  91.  
  92. function input()
  93.     mGUI()
  94.     while true do
  95.         ev, side, xPos, yPos = os.pullEvent("monitor_touch")
  96.         if ev == "monitor_touch" then
  97.             if xPos > 1 and xPos < 4 and yPos == 1 then
  98.                 table.insert(inp,wo)
  99.                 m.setCursorPos(sPos,4)
  100.                 shell.run("images/wo")
  101.             elseif xPos > 6 and xPos < 10 and yPos == 6 then
  102.                 table.insert(inp,2)
  103.                 m.setCursorPos(sPos,4)
  104.                 sPos = sPos+1
  105.             elseif xPos > 10 and xPos < 14 and yPos == 6 then
  106.                 table.insert(inp,wo)
  107.              shell.run("images/wo")
  108.             elseif xPos > 3 and xPos < 5 and yPos == 7 then
  109.                 table.insert(inp,4)
  110.                 m.setCursorPos(sPos,4)
  111.                
  112.                 sPos = sPos+1
  113.             elseif xPos > 7 and xPos < 9 and yPos == 7 then
  114.                 table.insert(inp,5)
  115.                 m.setCursorPos(sPos,4)
  116.                 m.write("*")
  117.                 sPos = sPos+1
  118.             elseif xPos > 11 and xPos < 13 and yPos == 7 then
  119.                 table.insert(inp,6)
  120.                 m.setCursorPos(sPos,4)
  121.                 m.write("*")
  122.                 sPos = sPos+1
  123.             elseif xPos > 3 and xPos < 5 and yPos == 8 then
  124.                 table.insert(inp,7)
  125.                 m.setCursorPos(sPos,4)
  126.                 m.write("*")
  127.                 sPos = sPos+1
  128.             elseif xPos > 7 and xPos < 9 and yPos == 8 then
  129.                 table.insert(inp,8)
  130.                 m.setCursorPos(sPos,4)
  131.                 m.write("*")
  132.                 sPos = sPos+1
  133.             elseif xPos > 11 and xPos < 13 and yPos == 8 then
  134.                 table.insert(inp,9)
  135.                 m.setCursorPos(sPos,4)
  136.                 m.write("*")
  137.                 sPos = sPos+1
  138.             elseif xPos > 3 and xPos < 5 and yPos == 9 then
  139.                 inp = {}
  140.                 m.setCursorPos(3,4)
  141.                 m.write("           ")
  142.                 sPos = 4
  143.             elseif xPos > 7 and xPos < 9 and yPos == 9 then
  144.                 table.insert(inp,0)
  145.                 m.setCursorPos(sPos,4)
  146.                 m.write("*")
  147.                 sPos = sPos+1
  148.             elseif xPos > 11 and xPos < 13 and yPos == 9 then
  149.                 checkInp()
  150.             end
  151.         end
  152.     end
  153. end
  154.  
  155. input()
  156.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement