Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script: IdentifyBuildersAndResources.lua
- -- Purpose: Lists builder huts, their locations, and their specific resource needs.
- local COLONY_INTEGRATOR_NAME = "colonyIntegrator" -- Adjust if your peripheral has a different name
- local colony = peripheral.find(COLONY_INTEGRATOR_NAME)
- if not colony then
- print("ERROR: Colony Integrator ('" .. COLONY_INTEGRATOR_NAME .. "') not found!")
- print("Make sure it's connected and the turtle is next to it.")
- return
- end
- print("Successfully connected to Colony Integrator.")
- print("Fetching building data...\n")
- local buildings = colony.getBuildings()
- if not buildings or #buildings == 0 then
- print("No buildings found in the colony data.")
- return
- end
- print("--- Builder Hut Identification & Resource Scan ---")
- local builderHutsFound = 0
- for i, building in ipairs(buildings) do
- -- We need to identify builder huts. Common ways they might be identified:
- -- 1. By name: e.g., "Builder's Hut", "Builder 1", "Builder Hut"
- -- 2. By type: The API docs show `type: string`. This might be like "minecolonies:builderhut" or similar.
- -- Let's try to catch common names and types. You might need to adjust this.
- local isLikelyBuilderHut = false
- if string.match(string.lower(building.name or ""), "builder") or string.match(string.lower(building.type or ""), "builder") then
- isLikelyBuilderHut = true
- end
- if isLikelyBuilderHut then
- builderHutsFound = builderHutsFound + 1
- print("\n-------------------------------------------------")
- print("Builder Hut Candidate Found:")
- print(" Name: " .. (building.name or "N/A"))
- print(" Type: " .. (building.type or "N/A"))
- print(" Level: " .. (building.level or "N/A"))
- if building.location then
- print(" Location: X=" .. building.location.x .. ", Y=" .. building.location.y .. ", Z=" .. building.location.z)
- -- Now, let's get resources for this specific builder hut
- print(" Attempting to get resources for this builder:")
- local resources = colony.getBuilderResources(building.location)
- if resources then
- if #resources > 0 then
- print(" Required Resources:")
- for _, res in ipairs(resources) do
- print(" - Item: " .. (res.displayName or res.item or "Unknown Item"))
- print(" Needed: " .. (res.needed or "N/A"))
- print(" Status: " .. (res.status or "N/A"))
- print(" Available: " .. tostring(res.available))
- print(" Delivering: " .. tostring(res.delivering))
- end
- else
- print(" This builder currently has no specific resource requests listed via getBuilderResources.")
- end
- else
- print(" Failed to get resource information for this builder (getBuilderResources returned nil).")
- print(" Make sure the coordinates are precise and the building is indeed a functional builder's hut.")
- end
- else
- print(" Location: Not specified in building data.")
- end
- print("-------------------------------------------------")
- end
- end
- if builderHutsFound == 0 then
- print("\nNo buildings identified as Builder Huts based on current criteria (name/type containing 'builder').")
- print("You might need to inspect the full list of buildings (remove the 'isLikelyBuilderHut' filter) to see their names/types and adjust the script.")
- end
- print("\nScan complete.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement