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

Remote-controlled turtle with a terminal

Started by Nina, 20 April 2013 - 12:36 PM
Nina #1
Posted 20 April 2013 - 02:36 PM
These are two very simple programs that let you control a turtle with a terminal.
Note that you need to have Node.js installed on the system you want to run this on and the http API enabled in ComputerCraft.

Usage:
  • Run the server component:
    node ./server.js
  • Put the client program on some turtle and run it, it should then be controllable through the terminal where the server program runs.
Controls:
  • W/A/S/D: These should be obvious
  • J: Mine block
  • L: Place block
  • I/J: Move up/down
  • Q: Quit
Server: http://pastebin.com/mmKd45r9
Client: pastebin get AJJneYs5 remote

As I said, these are pretty simple programs and are mostly just a proof-of-concept of something that's probably been done already.

Example usage of this could be using an SSH client on your phone to connect to your computer and run it from there, so you can use your phone to remote control a turtle.
Spongy141 #2
Posted 20 April 2013 - 02:40 PM
Looks nice, like the key options, but you should add a option for the user to enter there own script to be run. Also would be nice to see some screenshots, but it wont affect most people from using or program.
Nina #3
Posted 20 April 2013 - 02:47 PM
Looks nice, like the key options, but you should add a option for the user to enter there own script to be run. Also would be nice to see some screenshots, but it wont affect most people from using or program.
What do you mean by adding an option for the user to enter their own script to run?
Also, there isn't really all that much to show in a screenshot, neither of the commands produce any output if running correctly.
Spongy141 #4
Posted 20 April 2013 - 03:05 PM
^
Like allow the user to type in "turtle.turnLeft()" and the turtle will turn left, from that the user can do some advanced scripts.
Nina #5
Posted 20 April 2013 - 03:21 PM
Where would you want the user to be able to type that? In the turtle's terminal or the remote control terminal?

The problem with it being done in the remote control terminal is that input is sent to the turtle character-by-character to make it as 'direct' or whatever as possible. Though perhaps I could add something where you press some key which then lets you enter a line of Lua which the turtle will execute.
Spongy141 #6
Posted 20 April 2013 - 03:28 PM
Yeah thats what I meant, but to get the turtle to use the code do

function turtleRunScript()
  file = fs.open("file",w") -- change file to anything you want.
  file.writeLine(msg) -- Change msg to what ever you set the message variable to for rednet messages.
  file.close()
  shell.run("file")
end