ComputerCraft Forums

ComputerCraft => Programs => APIs and Utilities => Topic started by: Valvate on Oct 04, 2018, 02:13 am

Title: Coordinate management library (beta)
Post by: Valvate on Oct 04, 2018, 02:13 am
Hey guys, this is my first forum post so my formatting is going to suck (sorry!)

i wrote a library / api / module for coordinate management, here ( is the github,
you can download it to your turtle with

Code Select
wget lib.luaimport it with
Code Select
local t = require('lib') or
local t = dofile('lib.lua')
It has all the normal turtle movement functions turning functions and digging functions, except it keeps track of coordinates and blocks dug.
also it can save positions and go back to them later
and move to coordinates (turtle starts at 0,0,0 facing north)
Code Select
print('I have dug '..t.blocks_dug..' Blocks!')
all the functions return true when they worked and return false when they failed (just like the turtle api!)
if you have any questions post a comment or ask me on discord :D

this is still a work in progress so please tell me how i can make it better :))

EDIT: if someone could tell me how to make the look function better that would be great, right now it just turns right until its at the correct orientation.
EDIT2: thanks Incin :D
EDIT3: added a bunch of test stuff that might not work
Title: Cordanite management library (beta)
Post by: Incin on Oct 04, 2018, 04:04 am
First of all, it's spelled 'coordinate' :P

I've used this in the past:

Code Select
function t.look(direction)
  if direction == orientation then return end

  if (direction - orientation) % 2 == 0 then
  elseif (direction - orientation) % 4 == 1 then

The way it works is the following:
Title: Cordanite management library (beta)
Post by: Valvate on Oct 04, 2018, 02:43 pm
thanks Incin, i'm going to use what you said. :D
(it was hardcore triggering me when he turned right 3 times to get the correct orientation :P)