Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Zer0AZ

Members
  • Content Count

    1
  • Joined

  • Last visited

Posts posted by Zer0AZ

  1. Hello everyone,

    I apologize first off if I should have just commented on that post, I just didn't want to necro / hijack the thread. I'm currently attempting to use BadCode's password door for the sake of learning. I've got the code to run, the password is accepted/denied appropriately. My issue however is upon running the code, it immediately emits a redstone signal from my redstone i/o (Using creative computer with a redstone i/o block attached) before a password is input. I assume from reading the code it's the part where it attempts to reset the door to its closed position? What seems to happen is upon accepting the password, the I/O actually ends the signal emission for the designated duration instead. I'm a bit too new to figure out why / how to fix this and was wondering if anyone would be able to help me understand how I can do fix it. I'll attach the code from the other post. The only edit I've made is adjusting the side that the power is emitting from. 

    EDIT#1: So after getting some help from the IRC we were able to figure out why I'm a failure haha. It seems that the issue stemmed from the default values in the code being assigned to emit at a level of 255 for the redstone (which I wasn't aware was for non-vanilla redstone wires). The code below has been updated accordingly for vanilla redstone wire. Thanks to @Vexatos for being awesome and catching that.

     

    --[[ 
      Password Lock Program for OpenComputers
    
    
      This program is designed to run indefinitely on a basic terminal to provide 
      password protection via redstone. It includes configurations for the door open
      duration, redstone output side, password, and an "admin" break password that will
      allow a user to gracefully terminate the program.
    
    
      By badcode9, 2016
    ]]
    
    local component = require("component")
    
    if not component.isAvailable("redstone") then
      io.stderr:write("This program requires either a Redstone Card Tier 1 or Redstone I/O block to run.\n")
      return
    end
    local rs = component.redstone
    
    local os = require("os")
    local term = require("term")
    local text = require("text")
    local sides = require("sides")
    
    
    
    
    --[[ Config ]]-----------------------------------------------------------------
    local pass = "password"
    local d = 5 -- Door open duration
    local s = sides.bottom -- Where to output redstone signal to open the door
    
    --[[ Door Control ]]-----------------------------------------------------------
    local function openDoor(duration)
      -- Open door for the duration provided, then close again.
      rs.setOutput(s, 15)
      os.sleep(duration)
      rs.setOutput(s, 0)
    end
    
    --[[ Main ]]-------------------------------------------------------------------
    
    -- Close door on init
    rs.setOutput(s, 0)
    
    while true do
     term.clear()
    
     -- Password Request
     print("Enter Password:")
     answer = text.trim(term.read(nil, false, nil, "*"))  -- Masking input characters; trim newline
     term.setCursor(1,2)
     term.clearLine()
    
     -- Password Check
     if answer == "admin" then -- admin pwd to break execution
      term.clear()
      print("Admin Override\n")
      return
     elseif answer == pass then
       print("ACCESS GRANTED")
       openDoor(d)
     else
       print("ACCESS DENIED")
       os.sleep(3)
     end
    end

     

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.