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

Rednet Fun!

Started by applesauce10189, 10 January 2014 - 12:33 AM
applesauce10189 #1
Posted 10 January 2014 - 01:33 AM
I've already had a rednet problem today on Ask a Pro but I prematurely went straight to ask a pro before actually checking common errors and such, well this time I checked and didn't find my error. I'm getting rednet:11:string expected


rednet.open()
while true do
id, message = rednet.receive()
if message == "open" then
  turtle.forward()
  turtle.turnLeft()
  turtle.dig()
  turtle.up()
  turtle.dig()
  turtle.down()
  turtle.back()
  turtle.turnRight()
  turtle.back()
  sleep(5)
  turtle.forward()
  turtle.turnLeft()
  turtle.place()
  turtle.up()
  turtle.place()
  turtle.down()
  turtle.back()
  turtle.turnRight()
  turtle.back()
end
end
by the way, sorry for the poor indenting, I made the "if" statement before the while true do, and before all the turtle. stuff and I didn't feel like fixing the indentations, it's still readable though, otherwise I would've taken the time to fix indentation.

EDIT: almost made a mistake. I accidentally typed the error on line 5. It's actually on line 11. Fixed.
Another edit: Line 11 is turtle.back() This seriously confuses me. Doesn't/shouldn't need a string.
Edited on 10 January 2014 - 12:39 AM
theoriginalbit #2
Posted 10 January 2014 - 01:37 AM
rednet.open requires a side
applesauce10189 #3
Posted 10 January 2014 - 01:40 AM
I swear the past day or so I have been making the most simple mistakes :'( thank you for helping me,
theoriginalbit #4
Posted 10 January 2014 - 01:41 AM
that's ok, everyone takes time to learn. just consult the wiki a little more. :)/>
applesauce10189 #5
Posted 10 January 2014 - 01:47 AM
New problem. In another computer with rednet I did rednet.send(1, "open") and when the turtle receives "open" it does nothing. If you look at the code it's supposed to move a bit and such, I made sure it's fueled, I also added a couple print's for checkpoints. The computer is sending "open" but the turtle isn't receiving it.
CometWolf #6
Posted 10 January 2014 - 01:52 AM
And the turtle's ID is 1?
applesauce10189 #7
Posted 10 January 2014 - 01:54 AM
And the turtle's ID is 1?
Probably not 1. It's a multiplayer server and I've made about 10 or so turtles, does the turtle's ID matter? Because if it does then that explains why this program isn't working.
Edit: on the turtle I made it immediately print both the received ID and message. I tested it and it printed neither. But the computer says it's sending it so I'm a bit confused here.
Edited on 10 January 2014 - 12:56 AM
CometWolf #8
Posted 10 January 2014 - 01:56 AM
The first number argument in rednet.send is the receiver id, so yeah it matters. Use rednet.broadcast otherwise.
theoriginalbit #9
Posted 10 January 2014 - 01:59 AM
but do note that rednet.broadcast will allow any computer listening to rednet to be able to receive the message, however when using rednet.send only the computer with the matching target ID will receive the message (well not completely true in the latest versions of ComputerCraft).

EDIT: You can find out the ID of the computer by typing `id` into the computer and pressing enter.
Edited on 10 January 2014 - 01:01 AM
applesauce10189 #10
Posted 10 January 2014 - 02:01 AM
I thought the ID part was for the channel it was sent on. Also, I would prefer not to use rednet.broadcast, I plan on having a lot of things controlled by rednet on seperate rednet programs but with similar commands sent. I don't want to open 5 different doors at once by using rednet.broadcast
theoriginalbit #11
Posted 10 January 2014 - 02:11 AM
No, if you wish to use channels then you must directly interface with the modem, you're unable to use the rednet api for this purpose.

Have a read of this tutorial to learn how to interface with modems directly.
Edited on 10 January 2014 - 01:12 AM
applesauce10189 #12
Posted 10 January 2014 - 02:13 AM
Thanks for the help, I now have a secret password door that is open/closed by a wireless turtle :)/>