Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clearScreen()
- term.clear()
- term.setCursorPos(1,1)
- end
- function scanChild(res)
- if res ~= nil then
- if res.children ~= nil then
- for key,val in pairs(res.children) do
- if val.status == "IN_PROGRESS" then
- rtext = rtext .. (val.name) .. "\n"
- researchCount = researchCount + 1
- end
- scanChild(val)
- end
- end
- end
- end
- function inBed(cit,bed)
- d = distance(cit,bed)
- if d == "P" or d == "T" then
- return false, d
- elseif d <=3 then
- return true, d
- else
- return false, d
- end
- end
- function showColonyInfo(showResourceInfo)
- citizens = colony.getCitizens()
- buildings = colony.getBuildings()
- text = "^d\n"..colony.getColonyName() .. " Info ID: " .. colony.getColonyID().. "\n^d\n" ..
- "Population: ".. #citizens .. " / ".. colony.maxOfCitizens() .." Happiness:" .. round(colony.getHappiness(),2) .. "/10\n"
- --if (info.mourning) then
- -- text = text .. " In Mourning\n"
- --ardata.mourning = false
- --else
- -- text = text .. "\n"
- --end
- if colony.isUnderAttack() then
- text = text .. "RAID IN PROGRESS\n"
- ardata.raid = true
- end
- idleCount = 0
- childCount = 0
- adultCount = #citizens
- housingMax = 0
- guardHousingMax = 0
- guardHousingUsed = 0
- guardCount = 0
- maxResearch = 0
- builderCount = 0
- studentCount = 0
- sleeping = 0
- sleepingMax = 0
- guardJobs = {"guardtower", "barrackstower", "combatacademy", "archery"}
- ardata.health = {}
- ardata.sleep = {}
- jobList = {}
- for _,citizen in pairs(citizens) do
- --get adult and child count
- if citizen.age == "child" then
- childCount = childCount + 1
- adultCount = adultCount - 1
- --Get jobless
- elseif citizen.work == nil then
- idleCount = idleCount + 1
- --get guard counts
- elseif hasValue(guardJobs, citizen.work.type) then
- guardHousingUsed = guardHousingUsed + 1
- guardCount = guardCount + 1
- --get Builder counts
- elseif citizen.work.type == "builder" then
- builderCount = builderCount + 1
- elseif citizen.work.type == "library" then
- studentCount = studentCount + 1
- end
- if citizen.work ~= nil then
- --Get a list of jobs
- if citizen.work.type ~= nil then
- if jobList[citizen.work.type] ~= nil then
- jobList[citizen.work.type] = jobList[citizen.work.type] + 1
- else
- jobList[citizen.work.type] = 1
- end
- end
- --This \/ may be erroneous.. only accounts for sleeping that have a job.
- --Get sleep count
- if citizen.work.type ~= "guardtower" and citizen.work.type ~= "barrackstower" then
- --debugText(citizen.status)
- asleep,d = inBed(citizen.location,citizen.bedPos)
- if citizen.isAsleep then
- sleeping = sleeping + 1
- --add directional marker to those that are not sleeping after 11oclock
- elseif (os.time() > 21 or os.time() < 6) then
- if d == "P" or d == "T" or d > 3 then
- table.insert(ardata.sleep,{name = citizen.name, distance = d, location = citizen.location})
- end
- end
- sleepingMax = sleepingMax + 1
- end
- end
- --get damaged citizens
- if citizen.health then
- if citizen.health < citizen.maxHealth then
- table.insert(ardata.health,{name = citizen.name, health = citizen.health, maxHealth = citizen.maxHealth, location = citizen.location})
- end
- end
- end
- --Building Data
- guardHouseLocations = {"barrackstower","combatacademy","archery"}
- for _,v in pairs(buildings) do
- if v.type == "citizen" then
- housingMax = housingMax + v.level
- elseif v.type == "tavern" then
- housingMax = housingMax + 4
- elseif hasValue(guardHouseLocations, v.type) then
- guardHousingMax = guardHousingMax + v.level
- elseif v.type == "guardtower" then
- guardHousingMax = guardHousingMax + 1
- elseif v.type == "university" then
- maxResearch = maxResearch + v.level
- end
- end
- ardata.idle = idleCount
- ardata.popCount = #citizens
- ardata.totalHousing = housingMax + guardHousingMax
- ardata.children = childCount
- ardata.builderCount = builderCount
- ardata.studentCount = studentCount
- ardata.sleeping = sleeping
- ardata.sleepingMax = sleepingMax
- text = text .. "Idle Citizens: " .. idleCount .. " Students: ".. studentCount ..
- "\nHousing: " .. #citizens-guardHousingUsed .. "/" .. housingMax ..
- "\nGuards: " .. guardHousingUsed .. "/" .. guardHousingMax ..
- "\nAdults: ".. adultCount .. " Children: " .. childCount
- --Building Queues
- qText = ""
- ardata.buildQueue = {}
- ardata.buildCount = 0
- ardata.totalQueueCount = 0
- ardata.activeBuildCount = 0
- queue = colony.getWorkOrders()
- for k,v in pairs(buildings) do
- --debugText(v.type)
- if v.isWorkingOn then
- ardata.buildCount = ardata.buildCount + 1
- qText = qText .. v.type .. v.level .. " to lvl " .. (v.level + 1) .. "\n"
- --if v.isClaimed == false then
- --text = text .. " (Queued)\n"
- --table.insert(ardata.buildQueue, {name = "building", toLevel = 0, queued = true})
- ardata.totalQueueCount = ardata.totalQueueCount + 1
- --else
- table.insert(ardata.buildQueue, {name = v.type, toLevel = (v.level + 1), queued = false})
- --ardata.activeBuildCount = ardata.activeBuildCount + 1
- --end
- end
- --if v.type == "WorkOrderDecoration" then
- --text = text .. "Decoration"
- --if v.claimedByBuilding == nil then
- --text = text .. " (Queued)\n"
- --table.insert(ardata.buildQueue, {name = "Decoration", toLevel = "N/A", queued = true})
- --ardata.totalQueueCount = ardata.totalQueueCount + 1
- --else
- --text = text .. "\n"
- --table.insert(ardata.buildQueue, {name = "Decoration", toLevel = "N/A", queued = false})
- --ardata.activeBuildCount = ardata.activeBuildCount + 1
- --end
- --end
- end
- for k,v in pairs(queue) do
- if v.isClaimed then
- ardata.activeBuildCount = ardata.activeBuildCount + 1
- end
- end
- qText = "^d\nConstructing: " .. ardata.activeBuildCount .. " / " .. ardata.builderCount .. "\n^d\n" .. qText .. "Total Queued - " .. ardata.buildCount
- --Resource Info
- if showBuilderResourceInfo then
- missingResources = {}
- for i=1, #buildings do
- if buildings[i].type == "builder" then
- buildResources = colony.getBuilderResources(buildings[i].location)
- for j = 1, #buildResources do
- resource = buildResources[j].item
- if missingResources[resource.displayName] ~= nil then
- missingResources[resource.displayName].needed = missingResources[resource.displayName].needed + resource.count
- missingResources[resource.displayName].onHand = missingResources[resource.displayName].onHand + buildResources[j].available
- missingResources[resource.displayName].inRoute = missingResources[resource.displayName].inRoute + buildResources[j].delivering
- else
- missingResources[resource.displayName] = {}
- missingResources[resource.displayName].needed = resource.count
- missingResources[resource.displayName].onHand = buildResources[j].available
- missingResources[resource.displayName].inRoute = buildResources[j].delivering
- end
- end
- end
- end
- mtext = "Needed Resources:\n"
- for k,v in pairs(missingResources) do
- if v.needed - v.onHand - v.inRoute > 0 then
- mtext = mtext .. k .." : " .. v.needed - (v.onHand + v.inRoute) .. "\n"
- end
- end
- end
- --Research
- research = colony.getResearch()
- rtext = ""
- researchCount = 0
- for _, y in pairs(research) do
- for _,v in pairs(y) do
- if v.status == "IN_PROGRESS" then
- researchCount = researchCount + 1
- rtext = rtext .. v.name .. "\n"
- end
- scanChild(v)
- end
- end
- rtext = "^d\nResearching: " .. researchCount .. " / " .. maxResearch .. "\n^d\n" .. rtext
- ardata.research = {}
- ardata.research.max = maxResearch
- ardata.research.currentAmount = researchCount
- return text, jobList, qText, rtext
- end
- return { showColonyInfo = showColonyInfo }
Advertisement
Add Comment
Please, Sign In to add comment