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

Startup script with redstone output activated

Started by VincentCAV, 30 October 2013 - 02:16 PM
VincentCAV #1
Posted 30 October 2013 - 03:16 PM
Hey guys,

I got this script going, right now when it starts up it starts with the redstone output deactivated, now I want it when it starts up to start with redstone output activated.

Here's the code:


function os.pullEvent()
	local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
	if event == "terminate" then
		 print ("====== Reboot disabled, please enter password:")
		sleep(2)
	end
	return event, p1, p2, p3, p4, p5
end
function write()
  term.clear()
  term.setCursorPos(1, 1)
end
local pass = "123"
local side = "bottom"
while true do
  write()
  print("====== Security System 1.1 ======")
  print("====== Please enter Password: ")
  local input = read("*")
  if input == pass then
	print("====== Security Enabled")
	rs.setOutput(side, true)
	sleep(2)
	local i = 9
	while i ~= 0 do
	  write()
	  print("====== Security Enabled")
print("====== Enter Password:")
	  local input = read("*")
		if input == pass then
		  i = i - 9
		  print("====== Security Disabled")
		  redstone.setOutput(side, false)
		  sleep(2)
		 else
		   print("====== Incorrect Password")
		   sleep(2)
		 end
	  end
	else
	  print("====== Incorrect Password")
	  sleep(2)
	 end
   end

Any suggestions?

Thanks.
Lyqyd #2
Posted 30 October 2013 - 06:50 PM
Split into new topic.

You've got a line in there that turns on a redstone output already, so you know how to do so. Just turn on a redstone output before you enter your while loop.
VincentCAV #3
Posted 31 October 2013 - 05:11 AM
That makes sense!

Managed to get it to work!


function os.pullEvent()
		local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
		if event == "terminate" then
				 print ("====== Reboot disabled, please enter password:")
				sleep(2)
		end
		return event, p1, p2, p3, p4, p5
end
function write()
  term.clear()
  term.setCursorPos(1, 1)
end
local pass = "123"
local side = "back"
redstone.setOutput(side, true)
while true do
  write()
  print("====== Security System 1.1 ======")
  print("====== Please enter Password: ")
  local input = read("*")
  if input == pass then
		print("====== Security Disabled")
		rs.setOutput(side, false)
		sleep(2)
		local i = 9
		while i ~= 0 do
		  write()
		  print("====== Security Disabled")
print("====== Enter Password:")
		  local input = read("*")
				if input == pass then
				  i = i - 9
				  print("====== Security Enabled")
				  redstone.setOutput(side, true)
				  sleep(2)
				 else
				   print("====== Incorrect Password")
				   sleep(2)
				 end
		  end
		else
		  print("====== Incorrect Password")
		  sleep(2)
		 end
   end