mirror of
https://github.com/kepler155c/opus
synced 2024-12-31 19:00:27 +00:00
blacklist items for turtle digging
This commit is contained in:
parent
366ab1736b
commit
0e3cb15356
@ -51,6 +51,7 @@ function turtle.resetState()
|
|||||||
state.digPolicy = noop
|
state.digPolicy = noop
|
||||||
state.movePolicy = _defaultMove
|
state.movePolicy = _defaultMove
|
||||||
state.moveCallback = noop
|
state.moveCallback = noop
|
||||||
|
state.blacklist = nil
|
||||||
Pathing.reset()
|
Pathing.reset()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -283,6 +284,34 @@ turtle.addPolicy('turtleSafe', function(action)
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local function isBlacklisted(b)
|
||||||
|
if b and state.blacklist then
|
||||||
|
for k, v in pairs(state.blacklist) do
|
||||||
|
if b.name:find(v) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
turtle.addPolicy('blacklist', function(action)
|
||||||
|
if action.side == 'back' then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local s, m = action.inspect()
|
||||||
|
if not isBlacklisted(s and m) then
|
||||||
|
return action.dig()
|
||||||
|
end
|
||||||
|
if s and m and m.name:find('turtle') then
|
||||||
|
return Util.tryTimes(math.random(3, 6), function()
|
||||||
|
os.sleep(.25)
|
||||||
|
if not action.detect() then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
turtle.addPolicy('digAndDrop', function(action)
|
turtle.addPolicy('digAndDrop', function(action)
|
||||||
if action.detect() then
|
if action.detect() then
|
||||||
local slots = turtle.getInventory()
|
local slots = turtle.getInventory()
|
||||||
@ -347,6 +376,9 @@ function turtle.set(args)
|
|||||||
elseif k == 'status' then
|
elseif k == 'status' then
|
||||||
turtle.setStatus(v)
|
turtle.setStatus(v)
|
||||||
|
|
||||||
|
elseif k == 'blacklist' then
|
||||||
|
state.blacklist = v
|
||||||
|
|
||||||
else
|
else
|
||||||
error('Invalid turle.set: ' .. tostring(k))
|
error('Invalid turle.set: ' .. tostring(k))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user