summaryrefslogtreecommitdiff
path: root/cactus.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-04-04 00:01:06 +0100
committerubq323 <ubq323@ubq323.website>2024-04-04 00:01:06 +0100
commit63fa89d70fdd8130e7eaf3fb9a21865d3faa6f8d (patch)
tree98b6f4fc0305abbe275aee1ea6bfd690f561fe16 /cactus.lua
parentba70cc937a8a8517014da24f496bfba450093d84 (diff)
launch cactus
Diffstat (limited to 'cactus.lua')
-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)