This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
RockLegend2's profile picture

RockLegend2's Coded Triple-Lock Security Door

Started by RockLegend2, 05 April 2012 - 01:44 AM
RockLegend2 #1
Posted 05 April 2012 - 03:44 AM
Pastebin Link to code:
http://pastebin.com/Cdn9wJCK



Raw Paste Data:

local function clearScreen()
term.clear()
term.setCursorPos(1, 1)
end
while true do
clearScreen()
passone = ("weapons")
passtwo = ("equipped")
passthree = ("armor")
print("Password One:")
if read("*") == passone then
clearScreen()
print("Password Two:")
if read("*") == passtwo then
clearScreen()
print("Password Three:")
if read("*") == passthree then
clearScreen()
print("Accepted")
redstone.setOutput("left", true)
redstone.setOutput("back", true)
redstone.setOutput("right", true)
sleep(8)
clearScreen()
redstone.setOutput("left", false)
redstone.setOutput("back", false)
redstone.setOutput("right", false)
else
clearScreen()
print("Denied")
sleep(3)
end
end
end
end


Sidenotes:
1) In the passone, passtwo, and passthree slots, the passwords are, expectably, customizable.
2) This does, indeed, keep your doors triple-locked, and also supports making three doors open one-by-one, as detailed with the three redstone.setOutput functions.
3) I do like feedback. Not because I'm narcisistic, but because I actually care about other people's opinions (to an extent). If you like it, say you like it. If there's problems (which I tried my best to fix), then tell me so I can improve.
4) Thanks very much to Casper7526's Interactive Computercraft Tutorial. Couldn't have done this without you!
virtualayu #2
Posted 05 April 2012 - 04:34 AM
well that is a nice one ^^ but i think it will be better with bundled cables (only if you're using red power)
RockLegend2 #3
Posted 05 April 2012 - 12:28 PM
well that is a nice one ^^ but i think it will be better with bundled cables (only if you're using red power)

I know basically nothing about the "red power" commands. Redstone commands were what I was introduced to through videos on Youtube and stuff back when Computercraft was for Minecraft 1.0.0.
virtualayu #4
Posted 05 April 2012 - 01:02 PM
may i propose you to use this ingame tutorial?
it is the one poposed in the tuto section of this forum it's a verygood one and a good start with bundled cables ^^

http://www.computercraft.info/forums2/index.php?/topic/13-interactive-computercraft-tutorial-in-game/
RockLegend2 #5
Posted 05 April 2012 - 06:07 PM
I have this program and I read through the entire thing. Guess I wasn't paying much attention to the bundled cables part. And I thought the "colors" part of it was rather strange, but informative.

(I mentioned that I read and used information from this in my Sidenote #4.)
Leo Verto #6
Posted 05 April 2012 - 07:01 PM
Nice little program! :)/>/> My first program was a lock, too, but I focussed on making it fancy and user-friendly.
MathManiac #7
Posted 19 May 2012 - 01:00 AM
Constructive Critisizm:

Indentions are a powerful tool, one that you should use.
indentions are basically ways to tell apart commands in 'blocks'. eg.

function doSomething(whoopie)
  print("Calculating whoopie...")
  if (not whoopie) then
    return nul
  end
  if (whoopie > 2) then
    return -9
  end
  return 9000
end

uses indentions. The next example is the same source code, but without indentions.

function doSomething(whoopie)
print("Calculating whoopie...")
if (not whoopie) then
return nul
end
if (whoopie > 2) then
return -9
end
return 9000
end

It's much harder to read. Think of a script the length of this, and multiply it by ten. Twenty. Fifty. It would be very hard to read. Also, a wall of text (no indentions) is next to impossible to debug if it doesn't work.
RockLegend2 #8
Posted 25 May 2012 - 12:46 PM
Constructive Critisizm:

Indentions are a powerful tool, one that you should use.
indentions are basically ways to tell apart commands in 'blocks'. eg.

function doSomething(whoopie)
  print("Calculating whoopie...")
  if (not whoopie) then
	return nul
  end
  if (whoopie > 2) then
	return -9
  end
  return 9000
end

uses indentions. The next example is the same source code, but without indentions.

function doSomething(whoopie)
print("Calculating whoopie...")
if (not whoopie) then
return nul
end
if (whoopie > 2) then
return -9
end
return 9000
end

It's much harder to read. Think of a script the length of this, and multiply it by ten. Twenty. Fifty. It would be very hard to read. Also, a wall of text (no indentions) is next to impossible to debug if it doesn't work.

I see what you mean, but I always found the "wall of text" much less daunting. The indented text always made all of the text look longer, more extensive, and far more complicated. The wall of text allows one to reference each line against each other so they aren't intimidated by more complex code. Also, Computercraft, the only place I use Lua in, tells me what the error is when I happen to trip in my coding run. I understand your concern, but I guess that's just helpful to everyone else.