Jump to content

Mars Project - Help with LUA code


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

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.

  • Similar Content

    • By GrantTheWizard
      Hello, I am new to LUA but not in programming. I am not understanding why my blockchain is not working.
      It is supposed to go 40 blocks down the row(Hence the for loop for count 40)
      Then when it gets to 40 come back(I need to change the 3 to a 2) but what it does right now is it digs the first wheat then stays there, then executes the turn then stops. Any ideas on how to fix?

    • By ZeZoBeatz
      As you see by the title, I am trying to help a random person on the server I play on with ComputerCraft. He made a program called LockExe and he just sells it on the server. It is very simple program. It just reads for the password and when you input it, the computer outputs a redstone signal for 5 seconds out the left side and then stops, then the computer reboots back up to the startup screen where it asks for the password again. But I just discovered the 'terminate' feature through ComputerCraft and I do not think he knows about it. So I am trying to edit his code so it disables/makes it harder to terminate the program so no-one can just steal his code. But everything that I have tried with the code keeps breaking the program. I keep using the os.pullEventRaw and that can read for the terminate event and can make it do other things besides just terminate but there are issues that I have found with using that. The first and main issue is that the os.pullEventRaw stops the programs entirely, meaning that it no longer allows me to type anything in the computer and it insteads waits for the input of the terminate event. I do the terminate event and whatever I made it do after the input happens, it does. Like if I tell it to type something out after I do ctrl + t, it tells me it. But this means that the password cannot be typed in. The second issue is after I use ctrl + t to do that terminate event, I can just do it again and it will terminate that so it will bypass it anyway. Like I said before, I am trying to help him out with his program just so no-one can steal it. Btw, he did not ask me to do any of this, I am doing it because I wanted to see if I could. But it seems I need help. This is the coding of his program just incase it helps.
    • By Nukious
      Hi, I'd like to know how I can change the terminal width and size via the ComputerCraft config for my Tekkit Classic server.
      I've tried changing terminal_width and terminal_height, but they only seem to work on singleplayer and if I edit them on the server's config, nobody is affected.
      Here is my config...
      #MLProperties: name (type:default) min:max -- information #MLProp : computerBlockID (int:207) #MLProp : diskDriveBlockID (int:208) #MLProp : diskItemID (int:4000) #MLProp : diskDriveGUIID (int:100) #MLProp : enableAPI_http (int:0) #MLProp : modem_range (int:64) #MLProp : modem_rangeDuringStorm (int:1) # #Fri Jul 22 00:59:10 CEST 2016 terminal_width=100 terminal_textColour_g=255 modem_rangeDuringStorm=16 computerBlockID=207 diskItemID=4000 diskDriveBlockID=208 enableAPI_http=1 terminal_textColour_b=0 checksum=440 terminal_textColour_r=0 modem_range=64 diskDriveGUIID=100 terminal_height=36 What do I do? As you can see I've set terminal_height and terminal_width to twice the default, however, only the HTTP API setting seems to actually change something in this config file.
      I'm quite stumped here, my singleplayer configuration has no effect on servers too!
      If possible, I'd like to make the default text colour green as well, to make the ComputerCraft terminals on my server look like the RedPower computers.
    • By 0x0
      So I recently started playing Tekkit 1.2.9g and was wondering if I should expect any future updates any time soon?
      It looks like the last update was over a year ago, and I couldn't find any official announcements or posts from the developers if they have stopped updating it.
      I'm asking primarily to see if the computer craft mod will be updated in a future patch.
    • By Tassyr
      So last time I checked out this pack it was just over a year ago. Before that I'd played for several months, then had to take a break. Originally, there was a bundled redstone wire and computercraft combo that worked. It worked great, in fact, and I designed a large amount of stuff around it. 
      When I resumed about a year ago, it was no longer working. I was told to wait a few months for an update that'd fix it and similar on this forum when I asked.
      Well guys, it's been a -year.- I realised I hadn't played in forever so I decided to give it a shot, and lo and behold! ... still no compatibility between computercraft and bundled redstone.
      Is there any way to get that sort of functionality back? Or has it just been flat out abandoned here? 
×
×
  • Create New...