mirror of
https://github.com/kepler155c/opus
synced 2024-11-05 08:26:16 +00:00
88 lines
1.8 KiB
Plaintext
88 lines
1.8 KiB
Plaintext
require = requireInjector(getfenv(1))
|
|
local Point = require('point')
|
|
|
|
local checkedNodes, nodes
|
|
|
|
local function addNode(node)
|
|
|
|
for i = 0, 3 do
|
|
local hi = turtle.getHeadingInfo(i)
|
|
local testNode = { x = node.x + hi.xd, z = node.z + hi.zd }
|
|
|
|
local key = table.concat({ testNode.x, testNode.z }, ':')
|
|
if not checkedNodes[key] then
|
|
nodes[key] = testNode
|
|
end
|
|
end
|
|
end
|
|
|
|
local function findObsidian()
|
|
repeat
|
|
local node = { x = turtle.point.x, z = turtle.point.z }
|
|
local key = table.concat({ node.x, node.z }, ':')
|
|
|
|
checkedNodes[key] = true
|
|
nodes[key] = nil
|
|
|
|
local _,b = turtle.inspectDown()
|
|
if b and (b.name == 'minecraft:lava' or b.name == 'minecraft:flowing_lava') then
|
|
if turtle.selectSlot('minecraft:water_bucket') then
|
|
turtle.up()
|
|
turtle.placeDown()
|
|
os.sleep(2)
|
|
turtle.placeDown()
|
|
turtle.down()
|
|
_, b = turtle.inspectDown()
|
|
end
|
|
end
|
|
|
|
if b and b.name == 'minecraft:obsidian' then
|
|
turtle.digDown()
|
|
addNode(node)
|
|
else
|
|
turtle.digDown()
|
|
end
|
|
|
|
print(string.format('%d nodes remaining', Util.size(nodes)))
|
|
|
|
if Util.size(nodes) == 0 then
|
|
break
|
|
end
|
|
|
|
local node = Point.closest(turtle.point, nodes)
|
|
if not turtle.gotoPoint(node) then
|
|
break
|
|
end
|
|
until turtle.abort
|
|
end
|
|
|
|
turtle.reset()
|
|
turtle.setPolicy(turtle.policies.digOnly)
|
|
local s, m = turtle.run(function()
|
|
repeat
|
|
|
|
checkedNodes = { }
|
|
nodes = { }
|
|
|
|
local _,b = turtle.inspectDown()
|
|
if not b or b.name ~= 'minecraft:obsidian' then
|
|
break
|
|
end
|
|
|
|
findObsidian()
|
|
if not turtle.selectSlot('minecraft:water_bucket') then
|
|
break
|
|
end
|
|
turtle.goto(0, 0)
|
|
turtle.placeDown()
|
|
os.sleep(2)
|
|
turtle.placeDown()
|
|
turtle.down()
|
|
until turtle.abort
|
|
end)
|
|
turtle.goto(0, 0, 0, 0)
|
|
turtle.reset()
|
|
if not s and m then
|
|
error(m)
|
|
end
|