Jump to content

Recommended Posts

Posted

So i was learning how to use the computercraft mod. I made this startupprogram that would let me enter a username and a password before opening a door. But for some reason i cant type in it. this is what the coding looks like:

if true then

.term.clear(doorcontrol)

.term.setCursorPos(1,1)

.print("username:")

.if input ~= "guzse" then

..print("password:")

..read = ("*")

..if input ~= "Dooracces" then

...redstone.setOutput ("bottom", true)

...sleep (3)

...redstone.setOutput ("bottom", false)

..end

.end

end

(points are space's)

And now i cant type, but it does show username: and password:

What did i do wrong?

Thank you anyway

Posted

You never told the program to ask for an input. before you compare the input to a string, you need to put "input = io.read()"

and instead of "read = ("*")", you want to ask for input again, with a * showing for each character, so you need to put "input = io.read("*")"

Also, may I point out that "~=" mean "does not equal", if you want the door to open only if the username and password are corrent, you need to put "==" rather than "~=".

Posted

You never told the program to ask for an input. before you compare the input to a string, you need to put "input = io.read()"

and instead of "read = ("*")", you want to ask for input again, with a * showing for each character, so you need to put "input = io.read("*")"

Also, may I point out that "~=" mean "does not equal", if you want the door to open only if the username and password are corrent, you need to put "==" rather than "~=".

thank you SO much! i just started with computercraft and know absolutely nothing about it! i am interested do, and i will learn! thanks alot!

Posted

You should try to find some lua tutorials online, plenty of interesting and important information. Then check computercraft wiki for the custom functions and APIs in computercraft (such as the particulars of the redstone API, or the colors API).

Posted

You should try to find some lua tutorials online, plenty of interesting and important information. Then check computercraft wiki for the custom functions and APIs in computercraft (such as the particulars of the redstone API, or the colors API).

i know. this was actually from a tutorial, but i think it got outdated. anyway thanks!

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.

×
×
  • Create New...