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

help with rednet

Started by noobtube2, 28 May 2012 - 05:49 AM
noobtube2 #1
Posted 28 May 2012 - 07:49 AM
i cant seem to get my computer to tell my turtle to do the lumberjack command
yes i have got modems on both

startup code:

rednet.open ("right")
os.pullEvent()
if event=="rednet.message" and p1==1
if p2 == "runlumberjack" then
shell.run("lumberjack")
end

sending message:

rednet.open ("top")
rednet.send (0,"runlumberjack")
Luanub #2
Posted 28 May 2012 - 08:16 AM
you need to capture the output of the event in vars when you do os.pullEvent()

startup

rednet.open ("right")
local event, p1, p2 = os.pullEvent()
if event=="rednet.message" and p1==1
if p2 == "runlumberjack" then
shell.run("lumberjack")
end
noobtube2 #3
Posted 28 May 2012 - 04:44 PM
doesn't seem to want to work

get this message when i use it

startup program used:

rednet.open ("right")
local event, p1, p2 = os.pullEvent()
if event=="rednet.message" and p1==1
if p2 == "runlumberjack" then
shell.run("lumberjack")
end

error message received:
bios : 206 : [string "startup"] : 4 : 'then' expected

i really want it to work for my turtle
MysticT #4
Posted 28 May 2012 - 05:23 PM
You are missing the "then" on the first if and an "end" to close it. Also, the event is "rednet_message", not "rednet.message".

rednet.open("right")
local event, p1, p2 = os.pullEvent()
if event=="rednet_message" and p1==1 then
  if p2 == "runlumberjack" then
    shell.run("lumberjack")
  end
end
noobtube2 #5
Posted 29 May 2012 - 12:39 AM
ty for that