summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cactus.lua21
1 files 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