Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Find the Geo Scanner peripheral
- local geoScanner = peripheral.find("geoScanner")
- if not geoScanner then
- print("No Geo Scanner found. Please attach one to the computer.")
- return
- end
- -- List of ores to scan for
- local ores = {
- "minecraft:coal_ore", "minecraft:iron_ore", "minecraft:gold_ore",
- "minecraft:diamond_ore", "minecraft:emerald_ore", "minecraft:lapis_ore",
- "minecraft:redstone_ore", "minecraft:copper_ore", "minecraft:nether_quartz_ore",
- "minecraft:nether_gold_ore", "minecraft:ancient_debris",
- -- Deepslate variants
- "minecraft:deepslate_coal_ore", "minecraft:deepslate_iron_ore",
- "minecraft:deepslate_gold_ore", "minecraft:deepslate_diamond_ore",
- "minecraft:deepslate_emerald_ore", "minecraft:deepslate_lapis_ore",
- "minecraft:deepslate_redstone_ore", "minecraft:deepslate_copper_ore"
- }
- -- Function to scan for a specific ore
- local function scanForOre(oreName)
- print("Scanning for " .. oreName .. "...")
- -- Get the scan radius (this method returns the maximum scan radius)
- local scanRadius = geoScanner.getRadius()
- -- Perform the scan
- local success, result = pcall(function()
- return geoScanner.scan(scanRadius)
- end)
- if not success then
- print("Scan failed: " .. tostring(result))
- return
- end
- -- Filter the results for the specific ore
- local oreLocations = {}
- for _, block in ipairs(result) do
- if block.name == oreName then
- table.insert(oreLocations, block)
- end
- end
- -- Sort ore locations by distance (closest first)
- table.sort(oreLocations, function(a, b)
- return (a.x^2 + a.y^2 + a.z^2) < (b.x^2 + b.y^2 + b.z^2)
- end)
- -- Display results
- if #oreLocations > 0 then
- print(string.format("Found %d locations of %s:", #oreLocations, oreName))
- for i, location in ipairs(oreLocations) do
- print(string.format("%d. x=%d, y=%d, z=%d", i, location.x, location.y, location.z))
- if i >= 5 then break end -- Limit to showing top 5 results
- end
- else
- print("No " .. oreName .. " found in scan range.")
- end
- end
- -- Function to analyze the current chunk
- local function analyzeChunk()
- local result, err = geoScanner.chunkAnalyze()
- if not result then
- print("Chunk analysis failed: " .. err)
- return
- end
- print("Chunk Analysis Results:")
- for oreName, count in pairs(result) do
- print(string.format("%s: %d", oreName, count))
- end
- end
- -- Function to display ore list with pagination
- local function displayOreList(page)
- local itemsPerPage = 10
- local startIndex = (page - 1) * itemsPerPage + 1
- local endIndex = math.min(startIndex + itemsPerPage - 1, #ores)
- print("\nOre List (Page " .. page .. "/" .. math.ceil(#ores / itemsPerPage) .. "):")
- for i = startIndex, endIndex do
- print(i .. ". " .. ores[i])
- end
- print("\nN: Next Page, P: Previous Page, S: Select Ore, B: Back to Main Menu")
- end
- -- Function to handle ore selection
- local function selectOre()
- local currentPage = 1
- while true do
- displayOreList(currentPage)
- local input = read():lower()
- if input == "n" and currentPage * 10 < #ores then
- currentPage = currentPage + 1
- elseif input == "p" and currentPage > 1 then
- currentPage = currentPage - 1
- elseif input == "s" then
- print("Enter the number of the ore you want to scan for:")
- local oreChoice = tonumber(read())
- if ores[oreChoice] then
- return ores[oreChoice]
- else
- print("Invalid ore selection.")
- end
- elseif input == "b" then
- return nil
- else
- print("Invalid input. Please try again.")
- end
- end
- end
- -- Main menu loop
- while true do
- print("\nGeo Scanner Menu:")
- print("1. Scan for specific ore")
- print("2. Analyze current chunk")
- print("3. Exit")
- local choice = tonumber(read())
- if choice == 1 then
- local selectedOre = selectOre()
- if selectedOre then
- scanForOre(selectedOre)
- end
- elseif choice == 2 then
- analyzeChunk()
- elseif choice == 3 then
- print("Exiting program.")
- break
- else
- print("Invalid choice. Please try again.")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment