Rednet code question.
#1
Posted 16 September 2013 - 04:30 AM
Computer:
rednet.open ("left")
while true do
local event, id, msg = os.pullEvent("rednet_message")
if msg == "foward" then
turtle.forward (10)
end
end
Turtle:
rednet.open ("left")
while true do
local event, id, msg = os.pullEvent(rednet_message)
if msg == "forward" then
turtle.forward (10)
end
end
Please Help thank you
#2
Posted 16 September 2013 - 11:39 AM
You clearly haven't read any of the stickies (I can tell because you didn't know where to post this), or even the titles of the sticky posts. Go read them.
When you come back, make sure that you have the correct code for the computer side in your post, because it looks to me like you pasted the turtle side twice.
#3
Posted 16 September 2013 - 07:10 PM
local side = "<sideinhere>"
rednet.open(side)
while true do
if redstone.getInput("right") then
-- either use broadcast or send, tho i use broadcast as my default
rednet.broadcast("forward")
else
sleep(2)
end
end
and for the turtle:
rednet.open ("right")
while true do
local event, id, msg = os.pullEvent("rednet_message")
-- for the broadcast you proberly only want the turtle to react from --the one computer that sends the message so that would meaby
-- be computer 1
if id == 1 then
if msg == "forward" then
turtle.forward (10)
end
end
end
Hope that helped
Edited by plazter, 16 September 2013 - 07:11 PM.
#4
Posted 17 September 2013 - 09:53 PM
#5
Posted 17 September 2013 - 10:02 PM
"<sideinhere>"
part which side am i ment to type and also im getting an error that says rednet : 44: too long witout yielding
any help would be much appreciated
#6
Posted 17 September 2013 - 10:24 PM
brattus123, on 17 September 2013 - 10:02 PM, said:
"<sideinhere>"
part which side am i ment to type and also im getting an error that says rednet : 44: too long witout yielding
any help would be much appreciated
Whichever side the wireless modem is on.
No idea about your error, post your full program (use code tags and format your code too please)
#7
Posted 21 September 2013 - 10:38 PM
Computer
local side = ("right")
rednet.open ("right")
while true do
if redstone.getInput ("left") then
rednet.broadcast ("forward")
else
sleep (2)
end
end
Turtle
rednet.open ("left")
while true do
local event, id, msg = os.pullEvent(rednet_message)
if id == 1 then
if msg == "forward" then
turtle.forward (10)
end
end
end
#8
Posted 21 September 2013 - 10:58 PM
Try an os.pullEvent("redstone") at the top of your loop, and get rid of that else sleep at the end. Then the code in the loop will only run every time the redstone state changes.
#9
Posted 21 September 2013 - 11:10 PM
Computer
local side = ("right")
rednet.open ("right")
os.pullEvent ("redtone")
while true do
if redstone.getInput ("left") then
rednet.send (23,"forward")
end
end
Turtle:
rednet.open ("left")
while true do
local event, id, msg = os.pullEvent(rednet_message)
if id == 1 then
if msg == "forward" then
turtle.forward (10)
end
end
end
#10
Posted 21 September 2013 - 11:25 PM
brattus123, on 21 September 2013 - 11:10 PM, said:
local side = ("right")
rednet.open ("right")
os.pullEvent ("redtone")
while true do
if redstone.getInput ("left") then
rednet.send (23,"forward")
end
end
Move the os.pullEvent inside the loop (after the while line)
Spell "redstone" inside that pullEvent correctly.
#11
Posted 21 September 2013 - 11:39 PM
Computer:
local side = ("right")
rednet.open ("right")
while true do
os.pullEvent ("redstone")
if redstone.getInput ("left") then
rednet.broadcast ("forward")
end
end
Turtle:
rednet.open ("left")
while true do
local event, id, msg = os.pullEvent(rednet_message)
if id == 1 then
if msg == "forward" then
turtle.forward (10)
end
end
end
#12
Posted 21 September 2013 - 11:44 PM
brattus123, on 21 September 2013 - 11:39 PM, said:
rednet.open ("left")
while true do
local event, id, msg = os.pullEvent(rednet_message)
if id == 1 then
if msg == "forward" then
turtle.forward (10)
end
end
end
Also, are you sure the rednet ID of the computer is 1?
#13
Posted 21 September 2013 - 11:47 PM
#14
Posted 21 September 2013 - 11:52 PM
#15
Posted 21 September 2013 - 11:54 PM
Computer:
local side = ("right")
rednet.open ("right")
while true do
os.pullEvent ("redstone")
if redstone.getInput ("left") then
rednet.send (23,"forward")
end
end
Turtle:
rednet.open ("left")
while true do
local event, id, msg = os.pullEvent("rednet_message")
if id == 18 then
if msg == "forward" then
turtle.forward (5)
end
end
end
#16
Posted 21 September 2013 - 11:59 PM
#17
Posted 22 September 2013 - 12:03 AM
#18
Posted 22 September 2013 - 01:22 AM
Turtle:
shell.run ("orbit")
end
then
shell.run ("orbit2")
end
then
shell.run ("orbit3")
end
then
shell.run ("orbit4")
end
Keep getting error bios :338: [string "orbitfull"] :2: '<eof>' expected
also the programs i'm trying to run are orbit , orbit2 , orbit3 and orbit4
#19
Posted 22 September 2013 - 01:29 AM
#20
Posted 22 September 2013 - 01:49 AM
Orbit:
length = 25 for i=1,length,1 do if turtle.detect(0) then end turtle.back (25) end
Orbit2:
turtle.turnRight (1) length = 17 for i=1,length,1 do if turtle.detect () then end turtle.back () end
Orbit3:
turtle.turnRight (1) length = 25 for i=1,length,1 do if turtle.detect () then end turtle.back () end
Orbit4:
turtle.turnRight (1) length = 17 for i=1,length,1 do if turtle.detect () then end turtle.back () end turtle.turnRight (1)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











