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

Code not working

Started by pwajnkaim, 20 August 2012 - 02:23 PM
pwajnkaim #1
Posted 20 August 2012 - 04:23 PM
I have made this small piece of code:

while true do
hold = os.pullEvent()
if hold == "redstone" then
term.clear
term.setCursorPos(1,1)
mon = peripheral.wrap( "left" )
mon.setTextScale(5)
if rs.testBundledInput("right", colors.green) then
mon.write ("1")
else
mon.clear()
end
end
end

But it doesnt seem to work (its supposed to display 1 on the monitor when it receives a green bundled input).
Could someone show me whats wrong with it.
Luanub #2
Posted 23 August 2012 - 09:47 AM
Try removing the space inbetween mon.write and the first (


mon.write("1")
Edited on 23 August 2012 - 07:51 AM
Graypup #3
Posted 24 August 2012 - 01:29 AM
I have made this small piece of code:

while true do
hold = os.pullEvent()
if hold == "redstone" then
term.clear
term.setCursorPos(1,1)
mon = peripheral.wrap( "left" )
mon.setTextScale(5)
if rs.getBundledInput("right") == colors.green then
mon.write("1")
else
mon.clear()
end
end
end
.
↑ That might've fixed it
Luanub #4
Posted 24 August 2012 - 09:32 AM
the rs.testBundledOutput() is correct and is much less error prone then getBundledInput. I would persoanlly stick with the original code.

I don't know how I missed this but your missing the ()'s after term.clear() as well as the extra space for the mon.write()