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

Bundled Cable Input Dection

Started by Darth_Ben17, 22 October 2013 - 11:24 PM
Darth_Ben17 #1
Posted 23 October 2013 - 01:24 AM
Hey guys, lately ive been attempting to make a monitor write "Lights Toggled" when the computer receives an input from Bunled Cable (white). Here is my code so far but it writes "Lights Toggled" when any colour goes on.

local monitor = peripheral.wrap("back"
while true do
  if os.pullEvent("redstone") then
	if rs.getBundledInput("right", colours.white) then
	monitor.write("Lights Toggled")
	end
  end
end
Edit: Im new to coding so im really bad right now :(/>
LBPHacker #2
Posted 23 October 2013 - 02:23 AM
Almost. Just make it remember if the white cable is on or not, and check if that changed in every redstone event:
local monitor = peripheral.wrap("back")
local last = rs.testBundledInput("right", colours.white)
while true do
    if os.pullEvent("redstone") then
        local current = rs.testBundledInput("right", colours.white)
        if last ~= current then
            last = current
            monitor.write("Lights Toggled")
        end
    end
end
Darth_Ben17 #3
Posted 23 October 2013 - 02:38 AM
Thnx that will work perfectly im new too coding (as a said) so im just getting it now :lol:/>
Darth_Ben17 #4
Posted 23 October 2013 - 02:40 AM
Also there was just one thing, I was testing some codes and I got some error and it said 30 in red, do u know what this means?
LBPHacker #5
Posted 23 October 2013 - 04:36 AM
30? Was that the whole error message?!
Darth_Ben17 #6
Posted 23 October 2013 - 04:47 PM
That was the whole error and I sometimes get it when I do ctrl+T instead of terminate its weird
Bomb Bloke #7
Posted 23 October 2013 - 05:22 PM
Are you sure it's an error, then? Given that it's solely a number and doesn't mention the term "error" at all, it's probably something specifically generated by your code.

That, or there is indeed more to the message then that. For what it's worth, most times you see a number within an error message, that number refers to the line number where the error occurred.
Darth_Ben17 #8
Posted 24 October 2013 - 02:17 AM
Yeah I know that but it hasn't been coming up since I redid my code so ill tell you if I see it again