From e9b1872709d8824a9489718c8dde0a5cc6ceccb7 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 4 Apr 2024 02:25:24 +0100 Subject: launch cactus --- cactus.lua | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cactus.lua b/cactus.lua index 6930d1f..17307fc 100644 --- a/cactus.lua +++ b/cactus.lua @@ -17,21 +17,19 @@ end local function ensure_modem() return ensure_equipped("modem","computercraft:wireless_modem_normal") end local function ensure_scanner() return error("aaa") end +local POS, FACING local function turte_pos_init() assert(ensure_modem()) - local POS = vector.new(gps.locate()) + POS = vector.new(gps.locate()) while turtle.detect() do turtle.turnRight() end turtle.forward() local newpos = vector.new(gps.locate()) turtle.back() - local FACING = newpos - POS - - return POS, FACING + FACING = newpos - POS end -local POS, FACING = turte_pos_init() local function moveby_y(delta) local fn = turtle.up @@ -134,12 +132,16 @@ end local datum = vector.new(-18, 128, -1837) -local function mainloop() +local function setup() + turtle_pos_init() + moveto(datum) turn_to_face(vector.new(0,0,1)) - dump_and_refuel() +end + +local function loop() repeat repeat do_column() @@ -161,6 +163,11 @@ local function mainloop() until POS.x <= -29 + moveto(datum) + turn_to_face(vector.new(0,0,1)) + + dump_and_refuel() + os.sleep(120) end -- cgit v1.2.3