Posted 02 January 2013 - 07:37 AM
[Solved]
I have a wireless computer that I want to control all my turtles with. I've written a program on that computer that can command all listening turtles to run a program.
Here's a simplified version of what I already have.
Computer: (ID: 1)
Turtle: (ID 2)
—-
The only problem is that the above only works for programs that are already on the turtle.
That's why I want to be able to send any line of lua to the turtle, have the turtle interpret it and run it, like so:
Computer: (ID: 1)
Turtle: (ID: 2)
I realise the fs API can be used to create a file, write the line of lua to it, and then execute it as a program and that should work. I just want to know if there's a better way.
Thanks.
I have a wireless computer that I want to control all my turtles with. I've written a program on that computer that can command all listening turtles to run a program.
Here's a simplified version of what I already have.
Computer: (ID: 1)
rednet.send(2, "dance")
Turtle: (ID 2)
while true do
command = rednet.receive()
shell.run(command)
end
—-
The only problem is that the above only works for programs that are already on the turtle.
That's why I want to be able to send any line of lua to the turtle, have the turtle interpret it and run it, like so:
Computer: (ID: 1)
command = "turtle.dig()" -- I want to send this string to the turtle
rednet.send(2, command)
Turtle: (ID: 2)
while true do
command = rednet.receive()
interpretAndRunLuaCode(command) -- I want the turtle to execute the string
end
I realise the fs API can be used to create a file, write the line of lua to it, and then execute it as a program and that should work. I just want to know if there's a better way.
Thanks.