AnonymusHochgenuss

geoscanner

Mar 27th, 2026 (edited)
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. local scanner = peripheral.find("geoScanner")
  2. if not scanner then error("Geo Scanner nicht gefunden!") end
  3.  
  4. local radius = 10
  5.  
  6. -- Namen-Zuordnung für schoenere Anzeige (optional erweiterbar)
  7. local oreNames = {
  8. ["minecraft:iron_ore"] = "Eisen",
  9. ["minecraft:deepslate_iron_ore"] = "Eisen",
  10. ["minecraft:coal_ore"] = "Kohle",
  11. ["minecraft:deepslate_coal_ore"] = "Kohle",
  12. ["minecraft:diamond_ore"] = "Diamant",
  13. ["minecraft:deepslate_diamond_ore"] = "Diamant",
  14. ["minecraft:gold_ore"] = "Gold",
  15. ["minecraft:deepslate_gold_ore"] = "Gold",
  16. ["minecraft:copper_ore"] = "Kupfer",
  17. ["minecraft:deepslate_copper_ore"] = "Kupfer",
  18. ["minecraft:redstone_ore"] = "Redstone",
  19. ["minecraft:deepslate_redstone_ore"] = "Redstone",
  20. ["minecraft:emerald_ore"] = "Smaragd",
  21. ["minecraft:deepslate_emerald_ore"] = "Smaragd",
  22. ["minecraft:lapis_ore"] = "Lapis",
  23. ["minecraft:deepslate_lapis_ore"] = "Lapis",
  24. ["minecraft:nether_gold_ore"] = "Gold",
  25. ["minecraft:nether_quartz_ore"] = "Quartz",
  26. ["tconstruct:cobalt_ore"] = "Cobalt",
  27. ["cobblemon:deepslate_fire_stone_ore"] = "FireStone",
  28. ["cobblemon:nether_fire_stone_ore"] = "FireStone",
  29. ["cobblemon:fire_stone_ore"] = "FireStone"
  30. }
  31.  
  32. -- Funktion: Wandelt Koordinaten in Richtungs-Strings um
  33. local function getDirection(x, y, z)
  34. local dir = ""
  35.  
  36. -- Z-Achse (Nord/Sued)
  37. if z < 0 then dir = dir .. math.abs(z) .. "N "
  38. elseif z > 0 then dir = dir .. z .. "S " end
  39.  
  40. -- X-Achse (West/Ost)
  41. if x < 0 then dir = dir .. math.abs(x) .. "W "
  42. elseif x > 0 then dir = dir .. x .. "O " end
  43.  
  44. -- Y-Achse (Oben/Unten)
  45. if y < 0 then dir = dir .. math.abs(y) .. "D"
  46. elseif y > 0 then dir = dir .. y .. "U" end
  47.  
  48. return dir
  49. end
  50.  
  51. -- HAUPTSCHLEIFE
  52. while true do
  53. term.clear()
  54. term.setCursorPos(1,1)
  55. print("=== ERZ TRACKER (Radius " .. radius .. ") ===")
  56.  
  57. local data = scanner.scan(radius)
  58. local results = {}
  59.  
  60. if data then
  61. for _, block in ipairs(data) do
  62. local name = block.name:lower()
  63. if name:find("ore") or name:find("raw") or name:find("ancient") or name:find("crystal") then
  64. -- Namen verschönern
  65. local displayName = oreNames[block.name] or block.name:match(":(.+)") or block.name
  66.  
  67. -- Nur das jeweils naechste Erz jeder Art speichern
  68. if not results[displayName] then
  69. results[displayName] = block
  70. else
  71. -- Wenn dieser Block naeher ist als der bisher gespeicherte, ersetzen
  72. local currentDist = math.abs(block.x) + math.abs(block.y) + math.abs(block.z)
  73. local old = results[displayName]
  74. local oldDist = math.abs(old.x) + math.abs(old.y) + math.abs(old.z)
  75. if currentDist < oldDist then
  76. results[displayName] = block
  77. end
  78. end
  79. end
  80. end
  81.  
  82. -- Ergebnisse ausgeben
  83. local line = 2
  84. for name, pos in pairs(results) do
  85. if line < 15 then -- Stoppt, bevor das Display voll ist
  86. term.setCursorPos(1, line)
  87. local dirString = getDirection(pos.x, pos.y, pos.z)
  88. print(name:sub(1,1):upper() .. name:sub(2) .. ": " .. dirString)
  89. line = line + 1
  90. end
  91. end
  92.  
  93. if line == 2 then
  94. print("Keine Erze gefunden.")
  95. end
  96. else
  97. print("Scan fehlgeschlagen (Cooldown?)")
  98. end
  99.  
  100. print("\n[Warte auf naechsten Scan...]")
  101. sleep(4) -- Pause zwischen den Scans (Cooldown-Schutz)
  102. end
Advertisement
Add Comment
Please, Sign In to add comment