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

Coded Redstone Pulse

Started by Kadecamz, 29 July 2012 - 01:19 AM
Kadecamz #1
Posted 29 July 2012 - 03:19 AM

conventinal = ("1337") -- This is  code to send a pulse to the left
heavy = ("2448") -- This code sends pulse to the right
textutils.slowWrite ("ENTER LAUNCH CODE FOR THE HEAVY OR CONVENTINAL MISSILES:")
input = read()
if  input == conventinal then
rs.setOutput ("left", true) -- Sides can be edited top right left ect
elseif input == heavy then
rs.setOutput ("right", true)
end
print("Launching!") -- You can change this to "EXECUTED"
sleep(5)
textutils.slowPrint("Action Completed (Assuming the code is correct)")
sleep(5)
os.shutdown() -- Optional, remove this if you wanna use your computer for other things.


This is a code to send a pulse to any of the sides you choose when you edit.
Also added some cool slowPrint. :ph34r:/>/>

lua is fun.
4forpengs #2
Posted 29 July 2012 - 03:51 AM
the topic name is a bit misleading
ciba43 #3
Posted 30 July 2012 - 09:18 PM
It looks too easy. Try to make more pulse.
Cranium #4
Posted 02 August 2012 - 03:18 PM
You could also do this:

correctpass="Pass"
input=read(*)
  if input == correctpass then
    rs.setOutput("side", true)
	 sleep(.2)
    rs.setOutput("side", false)
  else
    print("Incorrect Password")
    os.reboot()
end
Simple, and easy, and can be expanded with other elseif statements to do other things.
Pharap #5
Posted 06 August 2012 - 03:42 AM
The code is too lightweight. If you just want to output a redstone pulse, you can use the built in redpulse program.
Lyqyd #6
Posted 06 August 2012 - 06:54 AM
You could also do this:

correctpass="Pass"
input=read(*)
  if input == correctpass then
	rs.setOutput("side", true)
	 sleep(.2)
	rs.setOutput("side", false)
  else
	print("Incorrect Password")
	os.reboot()
end
Simple, and easy, and can be expanded with other elseif statements to do other things.

Second line should be input = read("*").
Pharap #7
Posted 06 August 2012 - 07:02 AM
You could also do this:

correctpass="Pass"
input=read(*)
  if input == correctpass then
	rs.setOutput("side", true)
	 sleep(.2)
	rs.setOutput("side", false)
  else
	print("Incorrect Password")
	os.reboot()
end
Simple, and easy, and can be expanded with other elseif statements to do other things.

Second line should be input = read("*").

It doesn't have to be, some password systems give you the option to hide your password or not, such as the ones for entering the WPA key when connecting to an internet connection.
Lyqyd #8
Posted 06 August 2012 - 07:13 AM
You could also do this:

correctpass="Pass"
input=read(*)
  if input == correctpass then
	rs.setOutput("side", true)
	 sleep(.2)
	rs.setOutput("side", false)
  else
	print("Incorrect Password")
	os.reboot()
end
Simple, and easy, and can be expanded with other elseif statements to do other things.

Second line should be input = read("*").

It doesn't have to be, some password systems give you the option to hide your password or not, such as the ones for entering the WPA key when connecting to an internet connection.

I was correcting the syntax, not the intent. He already had the asterisk, but was missing the quotes.
Pharap #9
Posted 06 August 2012 - 07:18 AM
You could also do this:

correctpass="Pass"
input=read(*)
  if input == correctpass then
	rs.setOutput("side", true)
	 sleep(.2)
	rs.setOutput("side", false)
  else
	print("Incorrect Password")
	os.reboot()
end
Simple, and easy, and can be expanded with other elseif statements to do other things.

Second line should be input = read("*").

It doesn't have to be, some password systems give you the option to hide your password or not, such as the ones for entering the WPA key when connecting to an internet connection.

I was correcting the syntax, not the intent. He already had the asterisk, but was missing the quotes.

So he did, I hadn't noticed. My console programming must be getting rusty.