Sectly_Playz

Minecraft Computer Craft Door Password

Jan 6th, 2021 (edited)
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.55 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. local side = "bottom"
  3. local password = "1527"
  4. local password2 = "152780"
  5. local opentime = 18.48
  6. while true do
  7.  term.clear()
  8.  term.setCursorPos(1,1)
  9.  print("-----------------------------------")
  10.  print("TEC_NO's Password/Passcode Script")
  11.  print("-----------------------------------")
  12.  print("Welcome User, ")
  13.  write("Password: ")
  14.  local input = read("*")
  15.  if input == password then
  16.   term.clear()
  17.   term.setCursorPos(1,1)
  18.   print("Password correct!")
  19.   rs.setOutput(side,true)
  20.   local speaker = peripheral.find("speaker")
  21.   speaker.playSound("minecraft:entity.player.levelup")
  22.   sleep(0.5)
  23.   speaker.playSound("minecraft:block.end_portal.spawn")
  24.   sleep(0.5)
  25.   speaker.playSound("minecraft:block.end_gateway.spawn")
  26.   sleep(0.5)
  27.   speaker.playSound("minecraft:ui.toast.challenge_complete")
  28.   sleep(opentime)
  29.   rs.setOutput(side,false)
  30.  elseif input == password2 then
  31.   term.clear()
  32.   term.setCursorPos(1,1)
  33.   print("Password correct!")
  34.   rs.setOutput(side,true)
  35.   local speaker = peripheral.find("speaker")
  36.   local notes = {
  37.       ["F#1"]=0,    ["F#2"]=12,
  38.       ["Gb1"]=0,    ["Gb2"]=12,
  39.       ["G1"]=1,     ["G2"]=13,
  40.       ["G#1"]=2,    ["G#2"]=14,
  41.       ["Ab1"]=2,    ["Ab2"]=14,
  42.       ["A1"]=3,     ["A2"]=15,
  43.       ["A#1"]=4,    ["A#2"]=16,
  44.       ["Bb1"]=4,    ["Bb2"]=16,
  45.       ["B1"]=5,     ["B2"]=17,
  46.       ["C1"]=6,     ["C2"]=18,
  47.       ["C#1"]=7,    ["C#2"]=19,
  48.       ["Db1"]=7,    ["Db2"]=19,
  49.       ["D1"]=8,     ["D2"]=20,
  50.       ["D#1"]=9,    ["D#2"]=21,
  51.       ["Eb1"]=9,    ["Eb2"]=21,
  52.       ["E1"]=10,    ["E2"]=22,
  53.       ["F1"]=11,    ["F2"]=23,
  54.                   ["F#3"]=24,
  55.                   ["Gb3"]=24,
  56.   }
  57.  
  58.   local function playNote(instrument,note,volume)
  59.       volume = volume or 1
  60.       speaker.playNote(instrument,volume,notes[note])
  61.   end
  62.  
  63.   local function harp(note,volume)
  64.       playNote("harp",note,volume)
  65.   end
  66.  
  67.   --test
  68.   local function a1()
  69.       harp "E1"
  70.       harp "G2"
  71.       harp "B2"
  72.   end
  73.  
  74.   local function a2()
  75.       harp "G2"
  76.       harp "C2"
  77.       harp "E2"
  78.   end
  79.  
  80.   local function a3()
  81.       harp "G2"
  82.       harp "B2"
  83.       harp "D2"
  84.   end
  85.  
  86.   local function a4()
  87.       harp "D1"
  88.       harp "F#2"
  89.       harp "A2"
  90.   end
  91.  
  92. --[[
  93. --local bpm = 136
  94. --local bps = bpm / 60
  95. --local spb = 1 / bps
  96. --local quarter = spb / 4
  97. --]]
  98.  
  99.   local function a(f,...)
  100.       local t={...}
  101.       for _,s in ipairs(t) do
  102.           if s > 0 then
  103.               f()
  104.               sleep(0.15 * s)
  105.           else
  106.               sleep(-0.15 * s)
  107.           end
  108.       end
  109.   end
  110.  
  111.   local function song()
  112.  
  113.       a(a1, 2,2,1,2,2)
  114.       a(a2, 1,2,2)
  115.       a(a3, 1,2,2)
  116.       a(a4, 1)
  117.  
  118.       a(a1, 2,2,1,2,2)
  119.       a(a2, 1)
  120.       a(a1, 2,2,1,2,2)
  121.       a(a2, 1)
  122.       a(a1, 2,2,1,2,2)
  123.  
  124.       a(a2, 1,2,2)
  125.       a(a3, 1,2,2)
  126.       a(a4, 1)
  127.  
  128.       a(a1, 2,2,1,2,2)
  129.       a(a2, 1)
  130.       a(a1, 2,2,1,2,2)
  131.       a(a2, 1)
  132.  
  133.       local t1 = 1/3
  134.       local t2 = 2/3
  135.       parallel.waitForAll(
  136.           function() a(a1, 2,2,1,2,2) end,
  137.           function() a(function()harp "B2" end, -t1,t1,t2,t2) end
  138.       )
  139.  
  140.       a(a2, 1,2,2)
  141.       a(a3, 1,2,2)
  142.       a(a4, 1)
  143.  
  144.       parallel.waitForAll(
  145.           function() a(a1, 2,2,1,2,2) end,
  146.           function() a(function()harp "B2" end, -t1,t1,t2,t2) end
  147.       )
  148.  
  149.       a(a2, 1)
  150.       a(a1, 2,2,1,2,2)
  151.       a(a2, 1)
  152.  
  153.       for i=1,4 do
  154.           parallel.waitForAll(
  155.               function() a(a1, 2,2,1) end,
  156.               function() a(function()harp "B2" end, -t1,t1,t2,t2) end
  157.           )
  158.       end
  159.  
  160.       for i=1,3 do
  161.           parallel.waitForAll(
  162.               function() a(a1, 2,2,1) end,
  163.               function() a(function()harp "B2" end, -t1,t1,t2,t1,t1) end
  164.           )
  165.       end
  166.  
  167.       parallel.waitForAll(
  168.           function() a(a1, 2,2,1) end,
  169.           function() a(function()harp "B2" end, -t1,t1,t2) end
  170.       )
  171.  
  172.       for j=1,3 do
  173.           a(a1, .5,.5,.5,.5,1)
  174.           a(a1, .5,.5,.5,.5,.5,.5,1)
  175.           a(a2, .5,.5,.5,.5,.5,.5,1)
  176.           a(a3, .5,.5,.5,.5,.5,.5,1)
  177.           a(a4, .5,.5)
  178.        
  179.           for i=1,3 do
  180.               a(a1, .5,.5,.5,.5,1)
  181.               a(a1, .5,.5,.5,.5,.5,.5,1)
  182.               a(a2, .5,.5)
  183.           end
  184.        
  185.           a(a2, .5,.5,.5,.5,1)
  186.           a(a3, .5,.5,.5,.5,.5,.5,1)
  187.           a(a4, .5,.5)
  188.       end
  189.  
  190.   end
  191.  
  192.   parallel.waitForAll(
  193.       song
  194.   )
  195.  
  196.   term.redirect(term.native())
  197.  
  198.   sleep(0.84)
  199.   rs.setOutput(side,false)
  200.  else
  201.   print("Password incorrect!")
  202.   sleep(2) -- Waits 2 seconds
  203.  end
  204. end
Advertisement
Add Comment
Please, Sign In to add comment