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

[Lua][Help] os.PullEvent with redstone input

Started by eromanrocks, 09 June 2012 - 04:49 AM
eromanrocks #1
Posted 09 June 2012 - 06:49 AM
Hello, I recently began using ComputerCraft (last night) and i am having some issues with a simple program i'm making to switch my nuclear reactor on/off. I got the basics down but im still having an issue, anyways this is my program:

function clear(test)
	 term.clear()
	 term.setCursorPos(1,1)
	 if test == nil then
		  print("Press 1 to turn on, 2 to turn off or 3 to exit")
	  end
end
clear()
while true do
	 event, param1 = os.pullEvent()
	  if event == "char" and param1 == "1" then
		 print("Turning on reactor")
		 sleep(2)
		 rs.setOutput("bottom",true)
		 clear()
	  elseif event == "char" and param1 == "2" then
		 print("Shutting Down")
		 sleep(2)
		 rs.setOutput("bottom",false)
		 clear()
	  elseif event == "char" and param1 == "3" then
		 print("Have a nice day!")
		 sleep(2)
		 break
	  end
end
clear(1)

what i want to do is to add an event so when the computer receives a redstone signal from an adjacent block , it can cut the redstone signal to the reactor.
what i have to the right is the remote thermal monitor from the ic2 reactor control addon, it emits a redstone signal when the reactor temperature reaches a value set by you

Spoiler

what i was thinking is something along the lines of:


elseif event == "redstone" and param1 == "right" then
monitor = peripheral.wrap("top")
term.redirect(monitor)
print("Reactor overheated, shutting down")
term.restore()
rs.setOutput("bottom",false)
sleep(3)
monitor.clear()

but when I apply the redstone signal nothing happens. can someone please correct my code?
Lyqyd #2
Posted 09 June 2012 - 07:10 AM
Redstone events don't throw parameters. Use redstone.getInput("right") instead.
eromanrocks #3
Posted 09 June 2012 - 07:32 AM
Thank you for the quick reply, how would i go to add that line into the code? (where does it go?)


EDIT: Nevermind, found out, thank you so much!