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

KdControl - A somewhat advanced Turtle Controller

Started by kd8lvt, 11 September 2016 - 05:47 PM
kd8lvt #1
Posted 11 September 2016 - 07:47 PM
KdControl

A somewhat advanced Turtle Controller

Coded By: kd8lvt



Have you ever checked out some turtle remote controllers, and thought to yourself, "These are aren't quite what I'm looking for." or maybe, "I wish this was a little more advanced"? Well, I'm glad you've checked this out, because this is what I am attempting to fix!

KdControl is a somewhat advanced turtle remote controller, aimed at more advanced users. It currently allows you to move your turtle, attack with it, mine with it (both upwards, forwards and downwards) as well as placing upwards, forwards and downwards. It can also make the turtle change inventory slots, all remotely.

The thing that makes KdControl different from other turtle remote controllers is that it works from anywhere in your world. (As long as the turtle is loaded and you can see what you are doing, that is.) Not only anywhere in your world, but you can control your turtle from a completely different instance of Minecraft. Even on different worlds, or across servers! (VIDEO GOING UP SOON)

This is thanks to "EnderCC" a really awesome API created by Sxw here on the CC forums. KdControl also has a somewhat WIP UI created using Touchpoint, by Lyqyd.

DOWNLOADS:
Installer (Made by my friend Funniray, and installs everything needed nice and neatly.): pastebin run zN6Uasjg
Installation Video: (There will be a video by Funniray once it is uploaded.)
Alternative Installation:
Touchpoint (only required on the Pocket Computer side): TOUCHPOINT (save it as "touchpoint")
EnderCC (required on both the Turtle and Portable Computer): ENDERCC (save it as "ender")
Turtle Program: pastebin get FQX2J2wv startup
Pocket Computer Program: pastebin get BFP5s115 startup
INSTALLATION:
1. Download all the required APIs (EnderCC on the turtle, EnderCC and Touchpoint on the Pocket Computer)
2. Download the actual programs on their respective devices
3. Set your UNIQUE channel in the config (both the turtle and pocket computer's channel must be the same). I suggest using a UUID generator, there are quite a few floating around online (like this one) If it is not unique, you'll interfere with other people's turtles, due to the way EnderCC works.
4. Enjoy!


THINGS TO NOTE:
1. This program does NOT auto-update, so check back every now and again to make sure there wasn't an update.
2. The current version is 0.0.1. You can see your version by editing the program, the first line is the version number.
3. If you need to update, UPDATE BOTH THE TURTLE, AND THE POCKET COMPUTER.
4. If your turtle is moving without you doing anything, change your channel, as someone else is using it.
5. Make sure you fuel your turtle. It won't move if you don't do so!
Edited on 12 September 2016 - 05:32 PM
TerraEnvy #2
Posted 12 September 2016 - 05:37 AM
Decided to give this a try and for the most part its fantastic. However I am running into the problem that it does not move forward when clicking the button for it. It's the only thing that seems to not work as I can have it mine, open inv, place blocks, and turn. But doesn't seem to receive the forward command.

Great work though!

-Terra
TerraEnvy #3
Posted 12 September 2016 - 05:39 AM
Can't edit since its awaiting mod approval, but also wanted to note that it looks like the move up and move down also are not working, so nothing involving turtle actual movement.

-Terra
Bomb Bloke #4
Posted 12 September 2016 - 09:35 AM
Quickly skimming the code, I don't see any fuel checks in there. You'll want to tank up before starting the script.

http://www.computercraft.info/wiki/Refuel
http://www.computercraft.info/wiki/Turtle.refuel#Fuel_Values
Edited on 12 September 2016 - 07:36 AM
kd8lvt #5
Posted 12 September 2016 - 07:13 PM
Yeah, sorry about not having any fuel checks, probably should have put that in there (whoops) I am planning on having a "Status" page of sorts where you can check fuel and other things. It will be in the next update, which should be coming soon ™

Thanks for checking out KdControl!
-Kd
TheRockettek #6
Posted 12 September 2016 - 09:06 PM
Hmm maybe coz it uses enderCC, i can make a cron php file that can send commands to my turtle via its server :D/>
Molinko #7
Posted 14 September 2016 - 12:26 AM
I'd like to recommend a lookup table for the remote turtle program commands. Lookup tables are easier to read and easier to expand with more commands later in dev for your ease of programming :)/>


--...
--------CONFIGURATION--------
channel = ... -- <- this will take a string argument at the start of the program. Now people wont have to edit the file, just start with 'program uuid'
--------ACTUAL CODE--------
os.loadAPI("ender")--Created by Sxw on the Computercraft Forums
-- os.loadAPI("commands") ?YAY?
ender.connect(channel)

-- This commands table could even be loaded with os.loadAPI  and stored separately in another file...
commands = {
  forward = function(n)
	n = tonumber(n) -- still a string from being sent over modem and parsed. Maybe parseCmd() can convert string arguments to the proper type when parsing...
	for i = 1, n do
	  turtle.forward()
	end
  end,
  up = ...,
  down = ...,
  select = function(slot) -- this helps readability x16 ;)/>
    turtle.select(tonumber(slot))
  end
  -- ... and more
  dig3 = function() -- custom commands are easier to deal with here in my opinion
	turtle.digUp()
	turtle.digDown()
	turtle.dig()
  end
}

function parseCmd(message)
  local f, args, cmd = string.gmatch(message, "%S+"), {}, nil
  cmd = f()
  for arg_ in f do
	args[#args+1] = arg_
  end
  return cmd, args
end

function slot(num)
  turtle.select(num)
end

while true do
  worked = false
  while worked == false do
	worked, command = ender.receive(channel)
	command, args = parseCmd(command)
	sleep(0.1)
  end
  if commands[command] then
	commands[command](unpack(args))
  else
	print('invalid command')
  end
end



Thanks for listening.. Hope this helps with some more ideas!
Edited on 13 September 2016 - 10:35 PM
Molinko #8
Posted 14 September 2016 - 12:42 AM
@TerraEnvy -

Sounds like someone needs to fuel the turtle…. :)/> Bomb Bloke is being subtle…