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

How do I create a passcode locked door?

Recommended Posts

Hello. I’m entirely new to Opencomputers and Lua scripts. I’m not familiar with the language nor can I code. I would like ask how to create a automatic door to open with a passcode. I have all the components just don’t know how to make it all work! 

Thanks in advance ;)

Link to post
Share on other sites

Make sure to change password and test side it goes 1-6. All you should need is a redstone card 

local component=require("component") --references all connected components

local r=component.redstone --Choose redstone from components list

local gpu=component.gpu --Choose gpu from components

local term=require("term") --References terminal commands

 

---- config section

local password="1234"

local delay=5 --time the door stays open

local side=5 --side of the door, test this

-----

 

local wrong=false

 

while true do

  term.clear() --Clear screen

  gpu.set(1,1,"Please enter the password")

  if wrong then

    gpu.set(1,1,"Password was wrong, try again")

    wrong=false

  end

  term.setCursor(1,2)

  local input=io.read() --wait for user input

  if input==password then

     r.setOutput(side,15) -- check if this is the correct function

     os.sleep(delay) 

     r.setOutput(side,0) -- same here

  else

     wrong=true

  end

end

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

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