Client (program on the turtle) :
while true do
rednet.open("right")
x,y,z=rednet.receive()
print(y)
shell.run(y)
end
Server (program on the computer) :
while true do
write"Command: "
input = read()
rednet.open("top")
rednet.broadcast(input)
end
while true do
rednet.open("right")
x,y,z=rednet.receive()
print(y)
shell.run(y)
end
while true do
write"Command: "
input = read()
rednet.open("top")
rednet.broadcast(input)
end
ya, I've always used "read()" didn't know about "io.read()" until a few days agoyou can do read()? because i always use io.read()
id = 17 --replace with id of your turtle
rednet.open("right")
print("what program do you want to run?")
program = io.read()
rednet.send(id, program)
code for turtle
rednet.open("right")
while true do
local x, y, z = rednet.recive(timeout)
shell.run(y)
end
Still does the same thing. when i type in: refuel. then it refuels but when i do: refuel all. then it says no such program.code for consolecode for turtleid = 17 --replace with id of your turtle rednet.open("right") print("what program do you want to run?") program = io.read() rednet.send(id, program)
rednet.open("right") while true do local x, y, z = rednet.recive(timeout) shell.run(y) end
i know. the thing is i was wondering how you could send args. do you know how you can?thats because refuel all is not a program, refuel is and when you type all it is a arg and you cant send args with how i did it
id = 17
rednet.open("right")
print("what program do you want to run")
program = io.read()
print("what arg do you want to send")
arg = io.read()
rednet.send(id, program)
rednet.send(id, arg)
shell.run("startup")
turtle
rednet.open("right")
while true do
local x, y, z = rednet.receive(timeout)
local x, y, z = rednet.receive(timeout)
shell.run(y,a)
end
Try this
run it on a turtle and a computer.Spoiler
local sSide = "top" -- side that moden is on computer term.clear() -- clear screen term.setCursorPos(1,1) -- sets cursos position to top left if turtle then -- test if it is a turtle rednet.open("right") while true do -- starts loop local event,arg1,arg2,arg3 = os.pullEvent("rednet_message") pcall( function() local tWords = {} for match in string.gmatch(arg2, "[^ \t]+") do table.insert( tWords, match ) end for i = 1,#tWords do if tonumber(tWords[i]) then tWords[i] = tonumber(tWords[i]) end end shell.run(unpack(tWords)) end ) end -- end of loop else -- if not a turtle then rednet.open(sSide) while true do rednet.broadcast(read()) end end