ComputerCraft scripty

Home Forums Tekkit Classic TeraWiki ComputerCraft scripty

This topic contains 0 replies, has 1 voice, and was last updated by Montey Montey 1 year, 6 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #276
    Montey
    Montey
    Keymaster

    Dveře na heslo

    Základní verze:
    edit startup

    print("Zadej heslo:")
    password = read("*")
    if password == "vase_heslo" then
      print("Spravne heslo.")
      redstone.setOutput("left", true)
      sleep(3)
      redstone.setOutput("left", false)
      os.shutdown()
    else
      print("Spatne heslo.")
      sleep(1)
      os.shutdown()
    end

    Pokročilé verze:
    edit startup

    os.pullEvent = os.pullEventRaw -- Zakaz Terminate
    
    -- Nastaveni
    password = "vase_heslo" -- heslo pro otevreni dveri
    debug = "vase_druhe_heslo" -- heslo pro zmeny v kodu
    side = "left" -- strana kde se nachazi dvere (left, right,...)
    time = 3 -- cas otevreni dveri
    
    print("Zadej heslo:")
    input = read("*")
    if input == password then
      print("Spravne heslo.")
      redstone.setOutput(side, true)
      sleep(time)
      redstone.setOutput(side, false)
      os.shutdown()
    elseif input == debug then
      exit()
    else
      print("Spatne heslo.")
      sleep(1)
      os.shutdown()
    end

    nebo další verze bez reboot nebo shutdown:
    edit startup

    os.pullEvent = os.pullEventRaw -- Zakaz Terminate
    
    -- Nastaveni
    password = "vase_heslo" -- heslo pro otevreni dveri
    debug_pwd = "vase_druhe_heslo" -- heslo pro zmeny v kodu
    side = "left" -- strana kde se nachazi dvere (left, right,...)
    time = 3 -- cas otevreni dveri
    
    function access_granted()
      print("Spravne heslo.")
      redstone.setOutput(side, true)
      sleep(time)
      redstone.setOutput(side, false)
      main()
    end
    
    function debug_mode()
      print("Debug rezim aktivovan")
      sleep(2)
      term.clear()
      term.setCursorPos(1,1)
    end
    
    function access_denied()
      print("Spatne heslo!")
      sleep(1)
      main()
    end
    
    function main()
      term.clear()
      term.setCursorPos(1,1)
      print("Zadej heslo:")
      input = read("*")
      if input == password then
        access_granted()
      elseif input == debug_pwd then
        debug_mode()
      else
        access_denied()
      end
    end
    
    main()
    • This topic was modified 1 year, 6 months ago by Montey Montey.
    • This topic was modified 1 year, 6 months ago by Montey Montey.
    • This topic was modified 1 year, 6 months ago by Montey Montey.
    • This topic was modified 1 year, 6 months ago by Montey Montey.
    • This topic was modified 1 year, 6 months ago by Montey Montey.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.