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

Problem with rednet.send (attempt to call nil)

Started by Eorum, 21 December 2013 - 09:12 AM
Eorum #1
Posted 21 December 2013 - 10:12 AM
So ive been trying to send a message from one turtle to another, but nothing I do seems to work. The turtle that recieves the message is working fine, it does its command after recieving the message,
but the turtle that sends it gets stuck. Im not very experienced with this so I might be missing some stupid mistake, but I can´t figure out what.
According to this : http://computercraft...ednet_%28API%29, the rednet.send command should be set up right. But I still get the "attempt to call nil" error..

I would very much appreciate your help!

(I don´t know how to be all fancy with the post, so a copy/paste is the best I can do)
——————————————————————————————————————
rednet = peripheral.wrap("right")
rednet.open(1)

–Removed a few functions here to keep the topic short, nothing that could ever mess with the rednet..

while true do
while redstone.getInput("back") do
Plant()
rednet.send(33,"plant") –This is the line that reads: "attempt to call nil"
Cut()
DropRefill()
end
sleep(.5)
end
——————————————————————————————————————
Lyqyd #2
Posted 21 December 2013 - 02:16 PM
Please post the whole code and the full text of the error message.
Eorum #3
Posted 21 December 2013 - 04:58 PM
Okey, heres the full code, and the exact error msg is: startup:67: attempt to call nil



———————————————–
rednet = peripheral.wrap("right")
rednet.open(1)

function Plant()
turtle.suckDown()
s = turtle.getItemCount(1)
turtle.dropDown(s-1)
turtle.select(1)
turtle.up()
turtle.forward()
turtle.forward()
turtle.down()
turtle.place()
end

function Cut()
turtle.dig()
turtle.forward()
while turtle.detectUp() do
turtle.digUp()
turtle.up()
end
while not turtle.detectDown() do
turtle.down()
end
turtle.turnRight()
turtle.turnRight()
turtle.up()
if turtle.detect() then
turtle.dig()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.turnLeft()
turtle.turnLeft()
turtle.down()
else
turtle.forward()
turtle.dig()
turtle.forward()
turtle.turnLeft()
turtle.turnLeft()
end
sleep(.5)
end

function DropRefill()
turtle.turnRight()
turtle.drop()
turtle.select(2)
turtle.drop()
turtle.select(3)
turtle.drop()
turtle.select(1)
turtle.turnLeft()
while turtle.getFuelLevel < 30 do
turtle.turnLeft()
turtle.suck()
turtle.refuel()
turtle.turnRight()
end
end

while true do
while redstone.getInput("back") do
Plant()
rednet.send(33,"plant") – line 67
Cut()
DropRefill()
end
sleep(.5)
end
Lyqyd #4
Posted 21 December 2013 - 05:11 PM
Ah, just noticed you were wrapping a peripheral to the name rednet at the beginning. There's no reason to do that. You'd want to either use the rednet API directly (remove the peripheral.wrap line) or use the modem API and change the variable you're wrapping the peripheral into to modem and use modem.transmit.