Advertisement
Myros27

Scan

May 16th, 2025
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.67 KB | None | 0 0
  1. -- Script: IdentifyBuildersAndResources.lua
  2. -- Purpose: Lists builder huts, their locations, and their specific resource needs.
  3.  
  4. local COLONY_INTEGRATOR_NAME = "colonyIntegrator" -- Adjust if your peripheral has a different name
  5.  
  6. local colony = peripheral.find(COLONY_INTEGRATOR_NAME)
  7.  
  8. if not colony then
  9.     print("ERROR: Colony Integrator ('" .. COLONY_INTEGRATOR_NAME .. "') not found!")
  10.     print("Make sure it's connected and the turtle is next to it.")
  11.     return
  12. end
  13.  
  14. print("Successfully connected to Colony Integrator.")
  15. print("Fetching building data...\n")
  16.  
  17. local buildings = colony.getBuildings()
  18.  
  19. if not buildings or #buildings == 0 then
  20.     print("No buildings found in the colony data.")
  21.     return
  22. end
  23.  
  24. print("--- Builder Hut Identification & Resource Scan ---")
  25. local builderHutsFound = 0
  26.  
  27. for i, building in ipairs(buildings) do
  28.     -- We need to identify builder huts. Common ways they might be identified:
  29.     -- 1. By name: e.g., "Builder's Hut", "Builder 1", "Builder Hut"
  30.     -- 2. By type: The API docs show `type: string`. This might be like "minecolonies:builderhut" or similar.
  31.     -- Let's try to catch common names and types. You might need to adjust this.
  32.     local isLikelyBuilderHut = false
  33.     if string.match(string.lower(building.name or ""), "builder") or string.match(string.lower(building.type or ""), "builder") then
  34.         isLikelyBuilderHut = true
  35.     end
  36.  
  37.     if isLikelyBuilderHut then
  38.         builderHutsFound = builderHutsFound + 1
  39.         print("\n-------------------------------------------------")
  40.         print("Builder Hut Candidate Found:")
  41.         print("  Name: " .. (building.name or "N/A"))
  42.         print("  Type: " .. (building.type or "N/A"))
  43.         print("  Level: " .. (building.level or "N/A"))
  44.         if building.location then
  45.             print("  Location: X=" .. building.location.x .. ", Y=" .. building.location.y .. ", Z=" .. building.location.z)
  46.  
  47.             -- Now, let's get resources for this specific builder hut
  48.             print("  Attempting to get resources for this builder:")
  49.             local resources = colony.getBuilderResources(building.location)
  50.  
  51.             if resources then
  52.                 if #resources > 0 then
  53.                     print("    Required Resources:")
  54.                     for _, res in ipairs(resources) do
  55.                         print("      - Item: " .. (res.displayName or res.item or "Unknown Item"))
  56.                         print("        Needed: " .. (res.needed or "N/A"))
  57.                         print("        Status: " .. (res.status or "N/A"))
  58.                         print("        Available: " .. tostring(res.available))
  59.                         print("        Delivering: " .. tostring(res.delivering))
  60.                     end
  61.                 else
  62.                     print("    This builder currently has no specific resource requests listed via getBuilderResources.")
  63.                 end
  64.             else
  65.                 print("    Failed to get resource information for this builder (getBuilderResources returned nil).")
  66.                 print("    Make sure the coordinates are precise and the building is indeed a functional builder's hut.")
  67.             end
  68.         else
  69.             print("  Location: Not specified in building data.")
  70.         end
  71.         print("-------------------------------------------------")
  72.     end
  73. end
  74.  
  75. if builderHutsFound == 0 then
  76.     print("\nNo buildings identified as Builder Huts based on current criteria (name/type containing 'builder').")
  77.     print("You might need to inspect the full list of buildings (remove the 'isLikelyBuilderHut' filter) to see their names/types and adjust the script.")
  78. end
  79.  
  80. print("\nScan complete.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement