Advertisement
Rukus308

Testing WIP

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