diff --git a/builder/apis/builder/turtle.lua b/builder/apis/builder/turtle.lua index b2f1e05..8d16149 100644 --- a/builder/apis/builder/turtle.lua +++ b/builder/apis/builder/turtle.lua @@ -609,7 +609,10 @@ function TurtleBuilder:gotoSupplyPoint() -- pathfind the rest of the way local pt = self:getBuildingCorner(turtle.point.y) turtle._goto({ x = pt.x, z = pt.z }) - turtle.setPolicy('none') + turtle.set({ + digPolicy = 'digNone', + attackPolicy = 'attackNone', + }) turtle.pathfind(self.supplyPoint) os.sleep(.1) -- random 'Computer is not connected' error... end @@ -1106,7 +1109,10 @@ function TurtleBuilder:build() local pt = self:getBuildingCorner(travelPlane) turtle.pathfind({ x = pt.x, z = pt.z, y = travelPlane }) - turtle.setPolicy('digAttack') + turtle.set({ + digPolicy = 'dig', + attackPolicy = 'attack', + }) for i = self.index, last, direction do self.index = i diff --git a/core/apis/turtle/level.lua b/core/apis/turtle/level.lua index 452f251..d78a333 100644 --- a/core/apis/turtle/level.lua +++ b/core/apis/turtle/level.lua @@ -133,7 +133,12 @@ function turtle.level(startPt, endPt, firstPt, verbose) error('failed to reach starting point') end - turtle.setPolicy("attack", { dig = dig }, "assuredMove") + turtle.set({ + digPolicy = dig, + attackPolicy = 'attack', + move = 'moveAssured', + }) + oldCallback = turtle.getMoveCallback() turtle.setMoveCallback(move) diff --git a/core/etc/scripts/obsidian b/core/etc/scripts/obsidian index e92abfa..f4a5597 100644 --- a/core/etc/scripts/obsidian +++ b/core/etc/scripts/obsidian @@ -75,7 +75,7 @@ end turtle.run(function() turtle.reset() - turtle.setPolicy(turtle.policies.digOnly) + turtle.set({ digPolicy = 'dig' }) local s, m = pcall(function() repeat diff --git a/farms/attack.lua b/farms/attack.lua index 69ef002..4747bee 100644 --- a/farms/attack.lua +++ b/farms/attack.lua @@ -49,7 +49,7 @@ equip('right', 'plethora:sensor', 'plethora:module:3') local sensor = device['plethora:sensor'] turtle.setMovementStrategy('goto') -turtle.setPolicy(turtle.policies.attack) +turtle.set({ attackPolicy = 'attack' }) local function findChests() if chest then diff --git a/farms/spawner.lua b/farms/spawner.lua index 487ae21..45f31a6 100644 --- a/farms/spawner.lua +++ b/farms/spawner.lua @@ -62,7 +62,7 @@ shell.openForegroundTab('spawner.lua %s')]], table.concat({ ... }, ' '))) end turtle.setMovementStrategy('goto') -turtle.setPolicy(turtle.policies.attack) +turtle.set({ attackPolicy = 'attack' }) local function dropOff() local inv = turtle.getSummedInventory() diff --git a/farms/superTreefarm.lua b/farms/superTreefarm.lua index 42c17ad..6efff9d 100644 --- a/farms/superTreefarm.lua +++ b/farms/superTreefarm.lua @@ -759,7 +759,10 @@ local tasks = { local s, m = turtle.run(function() turtle.reset() turtle.addFeatures('crafting') - turtle.setPolicy("digAttack") + turtle.set({ + attackPolicy = 'attack', + digPolicy = 'dig', + }) while not turtle.isAborted() do print('fuel: ' .. turtle.getFuelLevel()) diff --git a/farms/treefarm.lua b/farms/treefarm.lua index 781ac81..a5b76bd 100644 --- a/farms/treefarm.lua +++ b/farms/treefarm.lua @@ -517,7 +517,7 @@ local function fellTree(pt) desperateRefuel(FUEL_BASE + 100) turtle.clearMoveCallback() - turtle.setPolicy("attack") + turtle.set({ attackPolicy = "attack" }) return true end @@ -752,7 +752,7 @@ local tasks = { local s, m = turtle.run(function() turtle.addFeatures('level', 'crafting') - turtle.setPolicy("attack") + turtle.set({ attackPolicy = "attack" }) while not turtle.isAborted() do print('fuel: ' .. turtle.getFuelLevel()) diff --git a/miners/multiMiner.lua b/miners/multiMiner.lua index 02133bd..b327274 100644 --- a/miners/multiMiner.lua +++ b/miners/multiMiner.lua @@ -87,43 +87,47 @@ local function run(member, point) end local function dropOff() - if chestPoint then - local topPoint = Point.copy(chestPoint) - topPoint.y = topPoint.y + 2 - turtle.gotoY(topPoint.y) - while not turtle._goto(topPoint) do - os.sleep(.5) - end - - -- drop off - local box = Point.makeBox( - { x = chestPoint.x - 3, y = chestPoint.y + 3, z = chestPoint.z - 3 }, - { x = chestPoint.x + 3, y = chestPoint.y, z = chestPoint.z + 3 } - ) - turtle.setMovementStrategy('pathing') - turtle.setPathingBox(Point.normalizeBox(box)) - turtle.setPolicy('none') - while not turtle.moveAgainst(chestPoint) do - os.sleep(.5) - end - emptySlots({ }, chestPoint) - turtle.pathfind(Point.above(topPoint)) - turtle.setMovementStrategy('goto') - turtle.setPolicy('turtleSafe') - else - turtle.gotoY(spt.y) - turtle._goto(spt) - emptySlots({ }, Point.above(spt)) + -- go to 2 above chest + local topPoint = Point.copy(chestPoint) + topPoint.y = topPoint.y + 2 + turtle.gotoY(topPoint.y) + while not turtle._goto(topPoint) do + os.sleep(.5) end + + -- path to chest + local box = Point.makeBox( + { x = chestPoint.x - 3, y = chestPoint.y + 3, z = chestPoint.z - 3 }, + { x = chestPoint.x + 3, y = chestPoint.y, z = chestPoint.z + 3 } + ) + turtle.set({ + movementStrategy = 'pathing', + pathingBox = Point.normalizeBox(box), + digPolicy = 'digNone', + }) + while not turtle.moveAgainst(chestPoint) do + os.sleep(.5) + end + emptySlots({ }, chestPoint) + + -- path to 3 above chest + turtle.pathfind(Point.above(topPoint)) + turtle.set({ + movementStrategy = 'goto', + digPolicy = 'turtleSafe', + }) end if turtle then turtles[member.id] = turtle turtle.reset() - turtle.setPolicy('turtleSafe') - turtle.setMovementStrategy('goto') - turtle.setPoint(point) + turtle.set({ + attackPolicy = 'attack', + digPolicy = 'turtleSafe', + movementStrategy = 'goto', + point = point, + }) repeat local pt = getNextPoint(turtle) @@ -160,7 +164,7 @@ local function run(member, point) while not turtle._goto(Point.above(spt)) do os.sleep(.5) end - turtle.setPolicy('digOnly') + turtle.set({ digPolicy = 'dig' }) turtle._goto(spt) else turtle.gotoY(spt.y) @@ -220,7 +224,10 @@ local page = UI.Page { function page.info:draw() self:clear() self:write(2, 1, 'Turtles: ' .. Util.size(turtles)) - self:write(20, 1, 'Queue: ' .. Util.size(queue)) + if not chestPoint then + self:write(16, 1, 'No chest') + end + self:write(28, 1, 'Queue: ' .. Util.size(queue)) end function page:scan() diff --git a/miners/scanningMiner.lua b/miners/scanningMiner.lua index cfdeff6..1a5fc1d 100644 --- a/miners/scanningMiner.lua +++ b/miners/scanningMiner.lua @@ -626,9 +626,11 @@ Event.addRoutine(function() Util.writeTable(PROGRESS_FILE, mining) end - turtle.setPolicy(turtle.policies.digAttack) - turtle.setDigPolicy(turtle.digPolicies.turtleSafe) - turtle.setMovementStrategy('goto') + turtle.set({ + attackPolicy = 'attack', + digPolicy = 'turtleSafe', + movementStrategy = 'goto', + }) status('mining') Event.onTerminate(function() diff --git a/miners/simpleMiner.lua b/miners/simpleMiner.lua index 55b135e..46b9294 100644 --- a/miners/simpleMiner.lua +++ b/miners/simpleMiner.lua @@ -622,8 +622,10 @@ end turtle.run(function() turtle.reset() - turtle.setPolicy(turtle.policies.digAttack) - turtle.setDigPolicy(turtle.digPolicies.turtleSafe) + turtle.set({ + attackPolicy = 'attack', + digPolicy = 'turtleSafe', + }) unload() status('mining')