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

Program with multiple usernames and passwords

Question

Hi everybody i was working on a program and i just get stuck every time i try something

 

i wanted a program with multiple usernames and passwords in total 2 usernames and 2 passwords, but i cant get it working,

i put the code in if somebody want to look at it then it would be awesome

local component=require("component")
local r=component.redstone
local gpu=component.gpu
local term=require("term")
local text=require("text")
local computer=require("computer")
local os=require("os")


---- config section
local badgenumber="001"
local password="reserve"
local delay=1 --time the door stays open
local side=5 --side of the door, test this
-----


local wrong=false


while true do
	term.clear()
	gpu.set(1,1,"Unity City Federal Reserve")
	term.setCursor(1,2)
	gpu.set(1,3,"Please enter badgenumber")
  if wrong then
	gpu.set(1,1,"Unity City Federal Reserve")
	term.setCursor(1,2)
	gpu.set(1,3,"Please enter badgenumber")
	wrong=false
  end
	term.setCursor(24,3)
  else
	term.clear()
	gpu.set(1,1,"Unity City Federal Reserve")
	term.setCursor(1,2)
	gpu.set(1,3,"Please enter password")
  if wrong then
	gpu.set(1,1,"Unity City Federal Reserve")
	term.setCursor(1,2)
	gpu.set(1,3,"Please enter password")
	wrong=false
  end
	term.setCursor(24,3)
	input = text.trim(term.read(nil, false, nil, "*"))
  if input==password then
     r.setOutput(side,15) -- check if this is the correct function
     os.sleep(delay)
	 if input==password then
     r.setOutput(side,0) -- same here
  else
     term.clear()
	gpu.set(1,1, "Unity City Federal Reserve")
	gpu.set(1,3, "Acces Denied")
	os.sleep(delay)
	computer.shutdown(true)
  end
end
Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0


local component=require("component")

local rs=component.redstone

local gpu=component.gpu

local term=require("term")

local text=require("text")

local computer=require("computer")

local os=require("os")

----Config----

local delay1=1             --The delay what the redstone is on for (1)

local delay2=1             --The delay what the redstone is on for (2)

local side1=0              --The redstone side (1)

local side2=0              --The redstone side (2)

local username1="usr1"     --Username (1)

local username2="usr2"     --Username (2)

local password1="psw1"     --Password (1)

local password2="psw2"     --Password (2)

local firstmsg="Unity City Federal Reserve"      --The message that appears when the program is started

---- ---- ----

while true do

    term.clear()

    gpu.set(1,1,firstmsg)

    term.setCursor(1,2)

    gpu.set(1,3,"Please enter the username:")

    term.setCursor(27,3)

    local username=io.read()

    if username==username1 then

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

        term.setCursor(27,4)

   local password = text.trim(term.read(nil, false, nil, "*"))

if password==password1 then

rs.setOutput(side1,15)

            os.sleep(delay1)

            rs.setOutput(side1,15)

end

else

    if username==username2 then

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

        term.setCursor(27,4)

   local password = text.trim(term.read(nil, false, nil, "*"))

if password==password2 then

rs.setOutput(side2,15)

            os.sleep(delay2)

            rs.setOutput(side2,15)

end

else

gpu.set(1,6,"Wrong username!")

    os.sleep(3)

end

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
Answer this question...

×   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.