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

[Lock/Trap] Bong's Easy Lock And Trap

Started by BongHitz, 01 January 2013 - 11:19 AM
BongHitz #1
Posted 01 January 2013 - 12:19 PM
This is my first LUA script!!! Basically i have this opening two doors (both on right and left of computer) and if the password is wrong it will activate a dispenser to fire arrows at you( bottom redstone output). Also a master password for easy access back to your cmd line.


	os.pullEvent = os.pullEventRaw  -- Keeps from being Terminated
	pass = "letmein"   -- your password
	reset = "debug"	-- password to get to console
	print("Please Enter Password")  -- prints text
	input=read() -- reads text you typed in
	if input == pass then  -- checks to see if text is equal to password
	rs.setOutput("right",true) -- whatever side door is on /turn redstone on
	rs.setOutput("left",true)  -- whatever side door is on /turn redstone on
	sleep(3)				   -- keeps doors open for 3 seconds before closing
	rs.setOutput("right",false)  -- whatever side door is on /turn redstone off
	rs.setOutput("left",false)  -- whatever side door is on /turn redstone off
	os.reboot()   -- reboots back to lock program
	elseif input == reset then   -- if text was debug then does this
	print("Opening Terminal Console")  -- prints text
	return						  -- opens console for editing script
	else						  --or else lol
	print("WRONG...Prepare For DEATH!!!") --prints text
	for i = 1,5 do			   -- loops  5 times, change to how many times to fire from dispensers  
	rs.setOutput("bottom",true) -- whatever side trap is on/turn redstone on
	sleep(1)					-- pauses for 1 second
	rs.setOutput("bottom",false) --whatever side trap is on/turn redstone off
	sleep(1)					-- pauses for 1 second
	end					   --ends if statement
	end					   -- ends for statement
	os.reboot()			  -- reboots lock program
wilcomega #2
Posted 01 January 2013 - 01:46 PM
i haven't seen a program like this simple(bad) in a while on these forums… O.o
BongHitz #3
Posted 01 January 2013 - 03:07 PM
well for only 3 days in lua i feel proud of what ive made no matter what you say =)
Dlcruz129 #4
Posted 01 January 2013 - 03:40 PM
well for only 3 days in lua i feel proud of what ive made no matter what you say =)

Don't let wil discourage you. It's actually nice for a first program. Sure, a lot of people make door locks, but they're usually MUCH worse than this.
BustedEarLobes #5
Posted 01 January 2013 - 06:12 PM
well for only 3 days in lua i feel proud of what ive made no matter what you say =)

Good! And you should be proud of it. All it takes is practice and you can do amazing things with computercraft.

i haven't seen a program like this simple(bad) in a while on these forums… O.o

As for you, realize that it's rude to post non-constructive criticism on these posts. He worked hard and didn't do that bad of a job. I always think of when I just started out with computercraft and how proud I felt of the most basic scripts. I really wish you can -1 rep disrespectful people like you.
wilcomega #6
Posted 02 January 2013 - 12:49 AM
yeah sorry :)/> but i am sooo used to be seeing over a 1000 lines of code for an OS or an very big game. because they get usualy posted, anyways i am sorry
BongHitz #7
Posted 02 January 2013 - 04:38 AM
Thanks for the support!! Im learning more of the API now that I have a grasp of how LUA works. I have hours worth of reading ahead still lol.
GeniusName3 #8
Posted 03 January 2013 - 07:29 PM
your name is Bong,anyways,3 days of you in LUA is like 1 week for me in LUA..