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

[Question] Redstone event

Started by asyzard, 06 January 2013 - 12:06 PM
asyzard #1
Posted 06 January 2013 - 01:06 PM
Hi. I'd like to ask, why my program reacts just when the redstone signal goes form true to false? Is possible to make the opposite? Thanks.
My code
Spoiler

function getPos()
	print("Checking")
	repeat
		local rWhite = redstone.testBundledInput("right", colors.white)
		local rOrange = redstone.testBundledInput("right", colors.orange)
		local rMagenta = redstone.testBundledInput("right", colors.magenta)
   	 event, param  = os.pullEvent()
		if event == "redstone" then
			if rWhite then
				cabPos = 0
				print("I'm 1")
				return cabPos
			elseif rOrange then
				cabPos = 1
				print("I'm 2")
				return cabPos
			elseif rMagenta then
				cabPos = 2
				print("I'm 3")
				return cabPos
				   end
		end
	until (rWhite or rOrange or rMagenta) == true
end
Doyle3694 #2
Posted 06 January 2013 - 01:23 PM
By saying
rWhite = redstone.testBundledInput("right",colors.white)
You are basically saying "make a new variable called rWhite and make it equal to whatever is returned by redstone.testBundledInput("right",colors.white).

You should remove the parntheses and move the call of the function down so

local rWhite = redstone.testBundledInput

And

if rWhite("right", colors.magenta) then

do this for all colors ofcourse.
asyzard #3
Posted 06 January 2013 - 01:32 PM
Thank you :D/>