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

Rednet "Messaging"

Started by Kano, 10 November 2014 - 01:48 AM
Kano #1
Posted 10 November 2014 - 02:48 AM
I am working on a network for my base that uses a wireless pocket computer to tell computer in my base to do things, exp: Turning on and of the xp farm or Big Reactor. But in my testing i have found a very annoying little thing that is bugging me to no end.
When ever I send any thing to the Controller it prints out, table: (random things here) and then what I told it to and it is messing with me so much, can some one tell me why this is happening?

The Remote:
http://pastebin.com/uu1Tyv5v

The ComputerContoller:
http://pastebin.com/XBdBsYsz


Dragon53535 #2
Posted 10 November 2014 - 07:43 AM
Your problem is a known issue with rednet hosting and lookup. A simple fix would just be putting this inside your controller code, this will replace your WHOLE while true do loop

while true do
		id, message = rednet.receive()
		if type(message) == "table" then
			  --#I'm doing nothing here on purpose.
		elseif message == "clear" then --#Only if the top is false, then if this
				shell.run("monitor","right","clear")
		elseif message == "sendShell" then --#Same here
				shellID, shellMessage = rednet.receive()
				shell.run("monitor", monitorSide, shellMessage)
		else --#If nothing above happened, do this
				print(message)
		end
end
Now to me it looks like you didn't know what elseif's and elses were so i'll show you a generic one


local z = 2
if z == 3 then --#I'm false
  print("z = 3")
elseif z == 4 then --#I'm false
  print("z = 4")
elseif z < 3 then --#I'm true and I'll run
  print("z is less than 3")
elseif z == 2 then --#I'm true, however the one above me went. I won't run
  print("z = 2")
else --#If nothing else works, I run instead.
  print("Nothing above worked")
end
In this situation the only one that would be printed is the third one, Z is less than 3. Even though the one underneath it is z == 2, something above it said hey this is correct, and ran and then went to the end.
Edited on 10 November 2014 - 06:47 AM
Kano #3
Posted 10 November 2014 - 03:48 PM
Your problem is a known issue with rednet hosting and lookup. A simple fix would just be putting this inside your controller code, this will replace your WHOLE while true do loop

while true do
		id, message = rednet.receive()
		if type(message) == "table" then
			  --#I'm doing nothing here on purpose.
		elseif message == "clear" then --#Only if the top is false, then if this
				shell.run("monitor","right","clear")
		elseif message == "sendShell" then --#Same here
				shellID, shellMessage = rednet.receive()
				shell.run("monitor", monitorSide, shellMessage)
		else --#If nothing above happened, do this
				print(message)
		end
end
Now to me it looks like you didn't know what elseif's and elses were so i'll show you a generic one


local z = 2
if z == 3 then --#I'm false
  print("z = 3")
elseif z == 4 then --#I'm false
  print("z = 4")
elseif z < 3 then --#I'm true and I'll run
  print("z is less than 3")
elseif z == 2 then --#I'm true, however the one above me went. I won't run
  print("z = 2")
else --#If nothing else works, I run instead.
  print("Nothing above worked")
end
In this situation the only one that would be printed is the third one, Z is less than 3. Even though the one underneath it is z == 2, something above it said hey this is correct, and ran and then went to the end.
Ok this makes allot more sence now thank you, and I know about elseif I just had never thought about using them.