Advertisement
Rukus308

allthemodium scanner

Mar 25th, 2025
465
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.89 KB | Gaming | 0 0
  1. local scanner = peripheral.find("geoScanner")
  2. if not scanner then
  3.     print("No GeoScanner found! Attach a GeoScanner and try again.")
  4.     return
  5. end
  6.  
  7. print("Enter scan radius (max 8 recommended):")
  8. local radius = tonumber(read())
  9. if not radius or radius < 1 or radius > 16 then
  10.     print("Invalid radius. Using default of 16.")
  11.     radius = 16
  12. end
  13.  
  14. -- Ore color mappings
  15. local oreColors = {
  16.     ["allthemodium:allthemodium_ore"] = colors.orange,
  17.     ["allthemodium:allthemodium_slate_ore"] = colors.orange,
  18. }
  19.  
  20. print("Scanning continuously... Press Ctrl + T to stop.")
  21. while true do
  22.     local blocks = scanner.scan(radius)
  23.     if not blocks then
  24.         print("Scan failed. Retrying...")
  25.         sleep(5)
  26.         goto continue
  27.     end
  28.  
  29.     -- Clear the screen
  30.     term.setTextColor(colors.white)
  31.     term.setBackgroundColor(colors.black)
  32.     term.clear()
  33.  
  34.     -- Get screen size
  35.     local width, height = term.getSize()
  36.     local centerX, centerY = math.floor(width / 2), math.floor(height / 2)
  37.  
  38.     -- Draw detected ores with correct X/Z mapping
  39.     for _, block in ipairs(blocks) do
  40.         if oreColors[block.name] then
  41.             local x = centerX + block.x + 1 -- Left/Right
  42.             local y = centerY + block.z     -- Forward/Backward (mapped to screen Y)
  43.             local color = oreColors[block.name]
  44.             local char = ""
  45.            
  46.             -- Ensure coordinates stay within screen bounds
  47.             if x < 1 then
  48.                 x = 1
  49.                 char = "\27"
  50.             end
  51.             if x > width then
  52.                 x = width
  53.                 char = "\26"
  54.             end
  55.             if y < 1 then
  56.                 y = 1
  57.                 char = "\24"
  58.             end
  59.             if y > height then
  60.                 y = height
  61.                 char = "\25"
  62.             end
  63.            
  64.             -- Only draw pixel and marker within bounds
  65.             term.setBackgroundColor(colors.black)  -- Reset background
  66.             term.setTextColor(colors.white)        -- Reset text color
  67.             paintutils.drawPixel(x, y, color)
  68.            
  69.             term.setCursorPos(x, y)
  70.             -- Use term.write instead of print for markers
  71.             if char == "" then
  72.                 if block.y > 0 then
  73.                     term.write("+")
  74.                 elseif block.y < 0 then
  75.                     term.write("-")
  76.                 else
  77.                     term.write("=")
  78.                 end
  79.             else
  80.                 term.write(char)
  81.             end
  82.         end
  83.     end
  84.  
  85.     -- Draw player marker
  86.     term.setBackgroundColor(colors.black)
  87.     term.setTextColor(colors.white)
  88.     term.setCursorPos(centerX, centerY)
  89.     term.write("X") -- Player marker
  90.  
  91.     -- Reset screen colors
  92.     term.setBackgroundColor(colors.black)
  93.     term.setCursorPos(1, height)
  94.     sleep(1)  -- Wait before the next scan
  95.     ::continue::
  96. end
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement