Controlling a computercraft turtle remotely

Screen Shot 2015-10-18 at 7.16.59 PMScreen Shot 2015-10-18 at 7.17.30 PM

  1. Install Redis:
  2. Install Webdis
  3. Start a minecraft server with computercraft. You will need to have the http API enabled, which is the default.
  4. Put down a turtle I recommend a turtle with a crafting square and a pickaxe. I also recommend giving it a label. If you’re not trying the turtle replication challenge, either disable fuel or get a fair bit of starting fuel. Write down the computer’s id.
  5. Put down a chunk loader, if you’re in a modpack that has them, or DON’T log out. Computers and turtles can’t operate unless the chunks are loaded. If you’re putting down a chunkloader, I surrounded them with bedrock for foolproofing.
  6. Open the turtle and download the following script, changing “” to your own redis instance: pastebin get 8FjggG9w startup
    After you have the script saved as ‘startup’, run it or reboot the computer, and it should start listening for instructions.

    redis = "" 
    queue = "sshbot" .. os.getComputerID()
    return_queue = queue .. "_return"
    print("Remote webdis queues on icyego: " .. queue .. " and " .. return_queue)
    print("Receiving remote commands.")
    function exec(str)
      print("Running: " .. str)
      f ="tmp", "w")
      p = loadfile("tmp")
     status, err = pcall(function () p = loadfile("tmp"); return p() end)
      if status then
        status, ret = pcall(function() return textutils.serialize(err) end)
        if status then
          result = ret
          result = ""
        result = "Error: " .. err
      return result
    print("Now receiving remote commands.")
    while true do
      handle = http.get(redis .. "/BRPOP/" .. queue .. "/5.txt")
      if (handle and handle.getResponseCode() == 200) then 
        str = handle.readAll()
        str = string.sub(str, string.len(queue) + 1)
        result = exec(str)
        if string.find(result, "Error: ") then
          result2 = exec("return " .. str)
          if string.find(result2, "Error: ") then a=0 else result=result2 end
        end, "LPUSH/" .. return_queue .. "/" .. result)
  7. On your local machine, save the following, again replacing “”:
    function send() {
      curl -s -X POST -d "LPUSH/sshbot${1}/${2}" "" >/dev/null
    function get() {
      curl -s -X GET "${1}_return/20.json" | jq .BRPOP[1]
    if [ $# -ne 1 ]; then
      echo "Usage: rlwrap ./sshbot <COMPUTER_ID>"
      exit 1
    while read LINE; do
      send ${ID} "$LINE"
      get ${ID}
  8. Run: rlwrap ./sshbot <ID>, where <ID> is the turtle’s ID. You should be able to send commands to the computer now.
Tagged , , . Bookmark the permalink.

One Response to Controlling a computercraft turtle remotely

  1. Alex Booth says:

    Opening up ComputerCraft to the world using the http commands was an amazing idea from the developers!

Leave a Reply

Your email address will not be published. Required fields are marked *