Jump to content

Mars Project - Help with LUA code


Gomo

Recommended Posts

Hello guys,

 

I'm working on a small project and I got stuck.. It is about Computercraft. I know this isn't the right place to ask for help. (Hoping that somebody here knows a thing or two about Computercraft & is willing to help out)

Here's what I'm working on and what I'd like to achieve:

 

fVLFv8z.png

 

I got a computer on right side and I'd like to have constant redstone signal on top (for the red lights) -> "no go / closed air lock doors"

And when I right click on it, it asks for the launch permission password, if you enter the correct password it sends a redstone signal on the bottom block for 40 seconds which then lights up the green lights and opens up the air lock frame.

After 40 seconds it reboots/restarts.

 

And this is what I wrote so far, of course it doesn't work, hence why I seek for help :/

("edit startup")

while true do
rs.setOutput("top",true)
print("Enter the launch password: ")
password = read()
if password == "blabla" then
print("Launch sequence has been initiated!")
rs.setOutput("top",false)
rs.setOutput("bottom",true)
sleep(40)
rs.setOutput("bottom",false)
os.shutdown()
end

Any help is appreciated and once again I apologize for posting here.

 

-kind regards-

 

Gomo

 

 

EDIT: Got the problem solved.

 

Here's the code for those who want something similar.

rs.setOutput("top",true)
rs.setOutput("bottom",false)

while true do
        print("Enter the launch password: ")
        password = read("*")
        
        if password == "blabla" then
                print("nLaunch sequence has been initiated!")
                rs.setOutput("top",false)
                rs.setOutput("bottom",true)
                sleep(40)
                rs.setOutput("bottom",false)
                rs.setOutput("top",true)
                print("Launch sequence complete.")
        else
                print("nInvalid password.")
        end
        
        sleep(3)
        term.clear()
        term.setCursorPos(1,1)
end

 

Edited by Gomo
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...