Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local geoScan = peripheral.find("geoScanner")
- function isNeighbor(block1, block2)
- return math.abs(block1.x - block2.x) <= 1 and
- math.abs(block1.y - block2.y) <= 1 and
- math.abs(block1.z - block2.z) <= 1
- end
- function scanForDiamondOre()
- local blocks = geoScan.scan(10)
- sleep(1)
- if type(blocks) ~= "table" then
- print("Error: geoScanner.scan() did not return a table.".. type(blocks))
- else
- local groups = {}
- for _, block in pairs(blocks) do
- if block.name == "minecraft:diamond_ore" or block.name == "minecraft:deepslate_diamond_ore" then
- local groupExists = false
- for _, group in pairs(groups) do
- for _, groupBlock in pairs(group) do
- if isNeighbor(block, groupBlock) then
- table.insert(group, block)
- groupExists = true
- break
- end
- end
- if groupExists then
- break
- end
- end
- if not groupExists then
- table.insert(groups, {block})
- end
- end
- end
- for _, group in pairs(groups) do
- local output = "Found diamond ore group with " .. #group .. " blocks at (" .. group[1].x .. ", " .. group[1].y .. ", " .. group[1].z .. ")"
- io.write(output .. "\n")
- while true do
- local event, key = os.pullEvent('key')
- if event == 'key' then
- break
- end
- end
- end
- end
- end
- scanForDiamondOre()
Advertisement
Add Comment
Please, Sign In to add comment