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

Rednet Networking Text Issue

Started by Lightbikemaster, 27 June 2014 - 03:01 AM
Lightbikemaster #1
Posted 27 June 2014 - 05:01 AM
Hello,

There I was, playing Galacticraft and ComputerCraft in Minecraft 1.6.4.

I decided to build a system, on the Moon, that indicated from the outside whether the Oxygen Seal was active on the inside of the Moon Base I built.

"Server" code, the computer connected to the Oxygen Detector.

rednet.open("right")
os.pullEvent(redstone.getInput("left))
if redstone.getInput("left")
then rednet.broadcast("Oxygen Inside")
print("Program Working")
else
rednet.broadcast("No Oxygen!")
print("Program Working, but no Oxygen")
end

"Client" code, the computer on the outside of the building connected to a big monitor showing the results

rednet.open("left")
while true do
print(rednet.receive)
sleep(400)
end

No errors were returned when these two scripts were ran, but instead of the "Client" computer showing "Oxygen Inside" or "No Oxygen!", it shows:
function: 122d1e6a

This being my first rednet project, I'm proud that it transmitted something, but unfortunately not the desired string.

Thanks for your time,
Lightbikemaster
Dog #2
Posted 27 June 2014 - 05:15 AM
You're trying to print what the variable rednet.receive is pointing to. I believe you want to print the output of the function instead. To do that use parentheses (aka brackets)

try replacing

print(rednet.receive)

with

print(rednet.receive())

However, rednet.receive() returns more than one value, so I don't know if that's actually going to work (without knowing offhand and without being able to test atm, I would guess it will either error or print the first value returned, which would be the sender's ID).

You should first capture the results of rednet.receive() in variables, then print the variable you want…

local id,message = rednet.receive()
print(message)
Edited on 27 June 2014 - 06:30 AM
Lightbikemaster #3
Posted 27 June 2014 - 07:30 AM
Thanks for your help! :)/> It works now.