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

rednet

Started by vRazgriz, 31 December 2016 - 10:49 PM
vRazgriz #1
Posted 31 December 2016 - 11:49 PM
I have been following a rednet tutorial and trying to understand it, however I have ran into a bit of a problem.
This is what I have been going off of.
Rednet Basic Part 1

I believe these two areas are what the error message is talking about, but I am not sure.

PC1

for i, side in ipairs(rs.getSides()) do --#Loop for each side on the computer that redstone can be used, these can also be used by modems.
if peripheral.getType(side) == 'modem' then --#Did we find a modem... Or some other peripheral?
  print('Found Modem On Side '..side.."!")
  rednet.open(side)
  wireless = peripheral.wrap(side)
  break --#Opened modem, dont open any others.
end
end
function waitForMessage(displayMessage)
local sender, message, protocol = rednet.receive()
if displayMessage then print(message) else return message end
end
waitForMessage(true)

PC2

for i, side in ipairs(rs.getSides()) do --#Loop for each side on the computer that redstone can be used, these can also be used by modems.
if peripheral.getType(side) == 'modem' then --#Did we find a modem... Or some other peripheral?
  print('Found Modem On Side '..side.."!")
  rednet.open(side)
  wireless = peripheral.wrap(side)
  break --#Opened modem, dont open any others.
end
end
function sendMessage(destination, message, protocol)
if destination and message then
  rednet.send(destination, message, protocol)
end
end
sendMessage(7, 'hey')

The computer that is waiting for the message is running fine, however the computer sending the message keeps giving me

bios:14: [string ".temp"]:2: ')' expected

Perhaps, I am biting off a bit more than I can chew at the moment for I am so new at computercraft.

Thank You
Raz
Edited on 01 January 2017 - 12:02 AM
KingofGamesYami #2
Posted 01 January 2017 - 12:58 AM
Please post your full code, you have a syntax error.
vRazgriz #3
Posted 01 January 2017 - 01:02 AM
Would having one of the computer hook up to an energy polyon affect it in anyway?
I also went back and looked, I had a wired modem hooked up to PC2. I believe that fixed the error. However, the message does not send.
full code posted
Edited on 01 January 2017 - 12:06 AM
KingofGamesYami #4
Posted 01 January 2017 - 02:32 AM
No. That is a syntax error which means it is a typo in your code, for example a misplaced semicolon.

Are you certain the code you posted is exactly the same as the code you are running? The error message points to line 2, but I do not see any errors.
Edited on 01 January 2017 - 01:36 AM
vRazgriz #5
Posted 01 January 2017 - 03:05 AM
I made pastebins of the code, then copy and pasted the code into the post. I believe I have corrected that issue, for I am no longer getting that issue. I do however have a new issue. Which if I understand correctly, it is because the computer is not sending the signal? I am sorry I am such a noob at this.

PC1

.temp:13: attempt to call nil
Edited on 01 January 2017 - 02:07 AM
Bomb Bloke #6
Posted 01 January 2017 - 03:48 AM
The thirteenth line of the code you've provided for PC1 attempts to call "waitForMessage", which you've defined a few lines above. Again you should be checking for typos - odds are you didn't enter the function name the same way every time.
vRazgriz #7
Posted 01 January 2017 - 04:53 AM
okay thank you, for got to capitalize the For in the

waitForMessage(true)

I just cannot get the message to send, no errors come up, the message does not send. I made sure the computer ID is correct.
Bomb Bloke #8
Posted 01 January 2017 - 06:04 AM
The rest of your code looks ok to me. Assuming it matches what's actually on your computers, it may be an issue of range.
vRazgriz #9
Posted 01 January 2017 - 09:20 PM
I have them right next to each other, to make it easier to learn. Could it be that I have another program running over rednet? I did put in the ID for what computer to send it to.