Computercraft Password Door help?D:

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

DaleDystopiq

New Member
Jul 29, 2019
3
0
0
Alright well I'm trying to get a password door down for a map. It's an adventure maze going up a tower- I believe we have 15 levels at the moment?- players will have to find their way through, collect an item, read it, input whatever is needed as the password and move on to the next level. I have been able to get that far. However if the player fails and gets the password wrong, then the area below their feet will open (do to the computer activating sticky pistons) and they'll fall back to the previous level.

This is where I get stuck. I'm not quite sure how to write in the "else" command. I can get dialogue through and it shows that it understands that the password is not correct, but actually activating anything is where I have the problem.

Here's what I have so far just for testing (I'm going off of the Wiki's example- if anyone wouldn't mind, I would love to learn this hands on but I'm horrible with any languages purely off of text and not really through a hands on effort.T.T):

local side = "left"
local password = "Yes."
while true do
term.clear()
term.setCursorPos(1,1)
write("Yes or No?")
term.setCursorPos(1,4)
write("Answer: ")
local input = read("*")
if input == password then
term.setCursorPos(1,6)
print("Please proceed to the next room.")
redstone.setOutput(side,true)
sleep(5)
redstone.setOutput(side,false)
else
term.setCursorPos(1,6)
write("I'm sorry, you are incorrect. Prepare for a fall.")
sleep(2)
term.setCursorPos(1,7)
write("Goodbye.")
sleep(2)
os.shutdown()
end
end

-------

Where/how would I use redstone to activate pistons? Would I have a trail of redstone below the comp and lead it to the piston or should I have a torch? I am such an inexperienced redstone nublet.:c I don't learn things without hands on help so if anyone would be able to, that'd be great.:3 I have not been able to find any good tutorials about this and it got me thinking- is this just a largely overcomplicated way to do this? Is there something easier? If someone could either tell me how to write it out for the comp and/or lay redstone/pistons out or show me a better way for executing this, I would be most thankful.:3

OH. Also how would you make it impossible to Ctl+T out of the program, as well as a way to over-ride that option if the need arises?o:

~Dale
 

RetroGamer1224

New Member
Jul 29, 2019
716
0
0
Have another redstone signal come out the other side. Snake dust or wire to the pistons needed to open up the floor. Have it sleep then turn off the signal to close pistons.
 

DaleDystopiq

New Member
Jul 29, 2019
3
0
0
...in layman's terms plz?;~;
As I said, I know nothing about redstone/compcraft.T.T
How would I have the comp activate the signal? So confused.><
 

VikeStep

New Member
Jul 29, 2019
1,117
0
0
you might like this program that has already been made. It disables terminating and has some configs to setup beforehand, you could probably modify the code to add in your custom text
 

AliveGhost

New Member
Jul 29, 2019
167
0
0
Also I think write. should be term.write, not sure though.

Sent from my HTC Desire X using Tapatalk 2
 

DaleDystopiq

New Member
Jul 29, 2019
3
0
0
Actually, I have figured it out. Turns out I need to write input = read(), not input = read("*") .-.
Oh well. Works like a charm now. However, if there is one more thing you might help with?

I'm looking to include two words to be accepted by a program for let's say, option A, and another 2 for option B. How would I go along this?

Say I have local answer1 = "A"
and I have local answer2 = "C"

Fair enough, right? We have if input == answer1 then blah blah blah elseif input == answer2 then blah blah blah else end. Makes sense, right? What if I want to add a "B" to answer1 and "D" to answer2? Would I simply state local answer1 = "A" and "C" then local answer2 = "B" and "D" orrrrr would I use an or statement? I know nothing about programming here and I'm looking everywhere trying to learn. D:
--
Also I think write. should be term.write, not sure though.

Write("") is perfectly fine. As is print(""), textutils.slowPrint(""), or textutils.slowWrite(""). I don't know if there are other ways to have text appear, but these are what I use.

EDIT: Nevermind, I'm an idiot. Just made local answer1 = "A", local answer2 = "B", local answer3 = "C", local answer4 = "D".

if input == answer1 or answer3 then blah blah blah.

However, is there another less lengthy way to do this?
I'm so sorry for the spam guys./.\ Just trying to learn this.:3