Advertisement
Rukus308

allthemodium scanner

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