summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cactus.lua40
1 files changed, 38 insertions, 2 deletions
diff --git a/cactus.lua b/cactus.lua
index 756dd89..8e0e887 100644
--- a/cactus.lua
+++ b/cactus.lua
@@ -17,5 +17,41 @@ local function ensure_scanner() return error("aaa") end
assert(ensure_modem())
-local w = vector.new(gps.locate())
-print(w)
+local POS = vector.new(gps.locate())
+local function get_facing()
+ while turtle.detect() turtle.turnRight() end
+ turtle.forward()
+ local newpos = vector.new(gps.locate())
+ turtle.back()
+ return newpos - POS
+end
+local FACING = get_facing()
+
+local function moveby_y(delta)
+ local fn = turtle.up
+ if delta < 0 then fn = turtle.down delta = -delta end
+ for i=1,delta do fn() end
+end
+
+local function rotatev(v,nq)
+ -- rotates v by n quarters
+ nq = nq%4
+ for i = 1,nq do
+ v.x,v.z = -v.z,v.x
+ end
+ return v
+end
+
+local v = vector.new(1,0,0)
+for i=1,4 do print(i,rotatev(v,i)) end
+
+local function moveby_xz(dv)
+ -- y component of dv is ignored
+
+
+
+
+
+local datum = vector.new(-18, 128, -1837)
+local dx = w-datum
+moveBy(dx)