summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cactus.lua21
1 files changed, 17 insertions, 4 deletions
diff --git a/cactus.lua b/cactus.lua
index 2419bc1..65f6c06 100644
--- a/cactus.lua
+++ b/cactus.lua
@@ -27,6 +27,7 @@ local function turtle_pos_init()
local newpos = vector.new(gps.locate())
turtle.back()
FACING = newpos - POS
+ print("init with",POS,FACING)
end
@@ -69,7 +70,6 @@ local function move_linear(n)
local dir = turtle.forward
if n < 0 then dir = turtle.back end
for i = 1,math.abs(n) do dir() end
- print(POS,n,FACING)
POS = POS + FACING*n
end
@@ -94,6 +94,7 @@ local function moveby(delta)
moveby_xz(delta)
end
local function moveto(target)
+ print("moving to",target)
moveby(target - POS)
end
@@ -107,15 +108,17 @@ local function do_column()
end
local function dump_and_refuel()
+ print("dumping produce")
os.sleep(1)
local modem = peripheral.wrap"top"
local self = modem.getNameLocal()
- print(self)
+ print("i am",self)
local ch = peripheral.find"sc-goodies:diamond_barrel"
for i=1,16 do
ch.pullItems(self, i)
end
while turtle.getFuelLevel() < 2000 do
+ print("refuelling")
for k,v in pairs(ch.list()) do
if v.name == "minecraft:lava_bucket" then
ch.pushItems(self, k, 1, 1)
@@ -141,6 +144,7 @@ local function setup()
end
local function loop()
+ print("harvesting")
repeat
repeat
do_column()
@@ -170,6 +174,15 @@ local function loop()
os.sleep(120)
end
-setup()
-while true do loop() end
+local function main()
+ setup()
+ while true do loop() end
+end
+
+while true do
+ local ok, err = pcall(main)
+ if not ok then print("err",err) end
+ os.sleep(5)
+end
+end