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

[error][rednet] rednet:347 error

Started by luewind, 21 November 2012 - 12:24 PM
luewind #1
Posted 21 November 2012 - 01:24 PM
I'm currently trying to have the computer that is controlling my elevator to send the current position to a group of computers that will display its general position on each floor. If i remove the line pointed out in the code below it works fine. Any subjection would be welcome. thanks


term.clear()
term.setCursorPos(1,1)
print("server is running")
local up = "left"
local down = "right"
local senders = { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24}
local monitors = { 16, 17, 18, 19, 20, 21}
local elvPos = 0
local posChange = 0
while true do
  rednet.open("back")
  senders, posChange, distance = rednet.receive()
  posChange=tonumber(posChange)
  rednet.close("back")
  while posChange ~= elvPos do
  rednet.send( monitors, tostring(elvPos), true)    <- the error is with this line
  term.clear()
  term.setCursorPos(1,1)
  print("server is running")
    if posChange < elvPos then
	  term.clear()
	  term.setCursorPos(1,1)
	  print("server is moving")
	  rs.setOutput(up, true)
	  sleep(0.5)
	  rs.setOutput(up, false)
	  sleep(0.5)
	  elvPos = elvPos - 1
    elseif posChange > elvPos then
	  term.clear()
	  term.setCursorPos(1,1)
	  print("server is moving")
	  rs.setOutput(down, true)
	  sleep(0.5)
	  rs.setOutput(down, false)
	  sleep(0.5)
	  elvPos = elvPos + 1
    else
	  sleep(3)
    end
  end
end
anonimo182 #2
Posted 21 November 2012 - 01:41 PM
Where line is the error?

Found it, in rednet.send you don't need a 3rd argument
luewind #3
Posted 21 November 2012 - 06:56 PM
i have tried removing it and it has no change, i still get the error at the same point.
Sammich Lord #4
Posted 21 November 2012 - 11:28 PM
You cannot pass a table to the rednet.send() function. You will have to send each message individually.
remiX #5
Posted 21 November 2012 - 11:46 PM
You can do this


for i = 1, #monitors do
    rednet.send(monitors[i], tostring(elvPos))
end