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

rednet.receive() timeout not working?

Started by throwaway4140, 20 July 2018 - 12:32 AM
throwaway4140 #1
Posted 20 July 2018 - 02:32 AM
Hello,

Whenever I try to specify the timeout in rednet.receive() it gives me the following error which I think is a bug:


startup.lua:38: bad argument #2 (expected number, got number)

This is the code I'm using. It's asks the turtles with ids 0,1,2,3,4 for their status.


if command == "next" then
  readyTurtles = 0

  for i = 0, 4 do
   id = 5
   rednet.send(i,"status")
   id,msg,protocol = rednet.receive(2)
  
   if id == i then
	print("ID " .. id .. ": ready")
	readyTurtles = readyTurtles + 1
   else
	print("ID " .. i .. ": not ready")
   end
  end

  if readyTurtles == 5 then
   rednet.broadcast("1337")
  end

else
  rednet.broadcast(command)
end

Using ComputerCraft1.80pr1

I have no clue what I'm doing wrong here, as the wiki does the same thing.
Bomb Bloke #2
Posted 20 July 2018 - 03:34 AM
It's a bug in the pre-release version of ComputerCraft you're using. It's fixed in later builds, check the links through my signature.
throwaway4140 #3
Posted 20 July 2018 - 01:00 PM
It's a bug in the pre-release version of ComputerCraft you're using. It's fixed in later builds, check the links through my signature.

Thank you so much! I thought I was running the latest version since I downloaded the mod using the Twitch launcher.