Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local scanner = peripheral.find("geoScanner")
- if not scanner then
- print("No GeoScanner found! Attach a GeoScanner and try again.")
- return
- end
- print("Enter scan radius (max 8 recommended):")
- local radius = tonumber(read())
- if not radius or radius < 1 or radius > 16 then
- print("Invalid radius. Using default of 16.")
- radius = 16
- end
- -- Ore color mappings
- local oreColors = {
- --["minecraft:coal_ore"] = colors.gray,
- --["minecraft:iron_ore"] = colors.lightGray,
- ["allthemodium:allthemodium_ore"] = colors.orange,
- ["allthemodium:allthemodium_slate_ore"] = colors.orange,
- --["minecraft:gold_ore"] = colors.yellow,
- --["minecraft:diamond_ore"] = colors.cyan,
- --["minecraft:redstone_ore"] = colors.red,
- --["minecraft:lapis_ore"] = colors.blue,
- --["minecraft:emerald_ore"] = colors.green,
- --["minecraft:nether_quartz_ore"] = colors.white,
- --["minecraft:copper_ore"] = colors.brown
- }
- print("Scanning continuously... Press Ctrl + T to stop.")
- while true do
- local blocks = scanner.scan(radius)
- if not blocks then
- print("Scan failed. Retrying...")
- sleep(5)
- goto continue
- end
- -- Clear the screen
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- term.clear()
- -- Get screen size
- local width, height = term.getSize()
- local centerX, centerY = math.floor(width / 2), math.floor(height / 2)
- -- Draw scan border
- --term.setTextColor(colors.white)
- --for dx = -radius, radius do
- -- paintutils.drawPixel(centerX + dx, centerY - radius, colors.white) -- Top border
- -- paintutils.drawPixel(centerX + dx, centerY + radius, colors.white) -- Bottom border
- --end
- --for dz = -radius, radius do
- -- paintutils.drawPixel(centerX - radius, centerY + dz, colors.white) -- Left border
- -- paintutils.drawPixel(centerX + radius, centerY + dz, colors.white) -- Right border
- --end
- -- Draw detected ores with correct X/Z mapping
- for _, block in ipairs(blocks) do
- if oreColors[block.name] then
- local x = centerX + block.x + 1 -- Left/Right
- local y = centerY + block.z -- Forward/Backward (mapped to screen Y)
- local color = oreColors[block.name]
- local char = ""
- -- Ensure coordinates stay within screen bounds
- if x < 1 then
- x = 1
- char = "\27"
- end
- if x > width then
- x = width
- char = "\26"
- end
- if y < 1 then
- y = 1
- char = "\24"
- end
- if y > height then
- y = height
- char = "\25"
- end
- -- Only draw within the screen bounds
- --if x >= 1 and x <= width and y >= 1 and y <= height then
- paintutils.drawPixel(x, y, color)
- term.setCursorPos(x, y)
- -- Print the direction
- if char == "" then
- if block.y > 0 then
- print("+")
- elseif block.y < 0 then
- print("-")
- else
- print("=")
- end
- else
- print(char)
- end
- --end
- end
- end
- -- Draw player marker
- term.setCursorPos(centerX, centerY)
- term.write("X") -- Player marker
- -- Reset screen colors
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1, height)
- sleep(1) -- Wait before the next scan
- ::continue::
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement