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

Only Works Once

Started by applesauce10189, 27 January 2015 - 09:40 AM
applesauce10189 #1
Posted 27 January 2015 - 10:40 AM
So, haven't played with Computercraft in a long time and decided to again, ran into a small problem,

term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.purple)
print("AppleOS v0")
rednet.open("top")
while true do
  local id, msg = rednet.receive()
  if msg == "rain" then
	rs.setOutput("back", true)
	sleep(1)
	rs.setOutput("back", false)
  end
end

That only works once every time the program is ran, I know a solution to this would be to just make the program then run itself, but that'd be a lazy workaround and I wanna know what I messed up on to avoid making this mistake in the future.

EDIT: Ignore this entire thing. Found my problem.
Edited on 27 January 2015 - 11:17 AM
InDieTasten #2
Posted 27 January 2015 - 03:43 PM
Why don't you post your solution, too? So when other people run into the same error they can see your solution ;)/>

I would guess that opening an already open modem raised an error, but to be sure please tell us your fix ;)/>
applesauce10189 #3
Posted 27 January 2015 - 04:43 PM
2 things:

1. That's actually startup on the computer it's meant for, and the computer only turns on upon loading the world, and on loading, the modem well be closed :P/>

2. The problem wasn't so much my program, but my method of testing it, the program works if you're smart enough to know how to properly broadcast something on rednet xD
InDieTasten #4
Posted 27 January 2015 - 04:51 PM
:D/> ok