79 posts
Posted 24 September 2012 - 06:31 PM
Really Simple program I'm using in my Batcave, Just make sure you have the computer over a sticky piston and the sticky piston is pushing the block over the hole. Only good if they can't avoid falling into the pit that your supposed to dig beneath the hole.
1.redstone.setOutput("bottom", true)
2.term.clear()
3.term.setCursorPos(1,1)
4.term.print("Name Please.")
5.sleep(5)
6.read()
7.if input = "Batman" then
8.print("No, I'm Batman")
9.redstone.setOutput("bottom", false)
10.sleep(5)
11.redstone.setOutput("bottom", true)
12.print("Goodbye Imposter.") ---I included dialogue like this because i plan to take my friend to the batcave during my let's play.
13.sleep(3)
14.end
15.os.reboot()
16.end
Not Tested yet, but supposed to be fine XD
Pastebin:
http://pastebin.com/MV3XDB6t
864 posts
Location
Sometime.
Posted 25 September 2012 - 12:44 AM
What if they type 'batman' instead of 'Batman'?
76 posts
Location
Konoha - Hidden Leaf Village
Posted 25 September 2012 - 10:52 AM
It might not work
79 posts
Posted 25 September 2012 - 11:36 AM
Well, just they're luck if they don't type it correctly on my Single Player World…lol
318 posts
Location
Somewhere on the planet called earth
Posted 25 September 2012 - 08:58 PM
if input = "Batman" then --line 7: You have = instead of ==
864 posts
Location
Sometime.
Posted 25 September 2012 - 10:11 PM
It might not work
if input = "Batman" then --line 7: You have = instead of ==
To help with not failing.
redstone.setOutput("bottom", true)
term.clear()
term.setCursorPos(1,1)
term.print("Name Please.")
sleep(5)
input = read() -- Read is not referred to as input because it wasn't established. Now you have input = read()
if string.lower(input) == "batman" then -- Changes input to lowercase
print("No, I'm Batman")
redstone.setOutput("bottom", false)
sleep(5)
redstone.setOutput("bottom", true)
print("Goodbye Imposter.") ---I included dialogue like this because i plan to take my friend to the batcave during my let's play.
sleep(3)
end
os.reboot()
end
3790 posts
Location
Lincoln, Nebraska
Posted 25 September 2012 - 10:13 PM
redstone.setOutput("bottom", true)
term.clear()
term.setCursorPos(1,1)
term.print("Name Please.")
local input = read() --still forgot to add input variable.
if string.lower(input) == "batman" then
print("No, I'm Batman")
redstone.setOutput("bottom", false)
sleep(5)
redstone.setOutput("bottom", true)
print("Goodbye Imposter.")
sleep(3)
end
os.reboot()
end
Edited with more fixes.
864 posts
Location
Sometime.
Posted 25 September 2012 - 10:17 PM
Edited with more fixes.
There's no reason for the local
if anything you could do
if string.lower(read()) == "batman" then
– code
end
3790 posts
Location
Lincoln, Nebraska
Posted 25 September 2012 - 10:35 PM
Meh. Still good to make variables local. Good habit to get into. The main problem was that he had just called read(), without being input = read(), so it would not have done anything.
79 posts
Posted 27 September 2012 - 03:51 PM
Uh oh…I just realized that this post contains "Malicious Content!"
:P/>/>
Nah JK XD
871 posts
Posted 27 September 2012 - 04:49 PM
There's no reason for the local
You don't need a specific reason to make a variable local. Every variable should be local unless you have a specific reason for making it global. Rampant and casual use of global variables can lead to some really bizarre-seeming bugs that are tricky to identify.
3790 posts
Location
Lincoln, Nebraska
Posted 27 September 2012 - 04:52 PM
You don't need a specific reason to make a variable local. Every variable should be local unless you have a specific reason for making it global. Rampant and casual use of global variables can lead to some really bizarre-seeming bugs that are tricky to identify.
Especially in cases like mine that have programs being as long as 2500 lines(working to separate it out), and setting global variables willy-nilly….I have never had a harder time tracking down bugs than switching that ugly code to local variables and functions….