Way to change all population numbers with a single stroke

I have thousands of planets set up with populations. As I've worked on my project, I realize I underestimated all these figures, and I'd like to multiply them all by 10 or so.

So for example if Planet A used to have population 100, I would like to change it to be 1000. If B had 50, I'd like to change it to 500. Is there a way I can add a multiplier to my project file somehow so that it will automatically add an extra 0 to all my populations? Or do I need to go and change them planet by planet. Thanks!

Comments

  • No, no simple way to do that from within the program. You'll need a script. Save the below in the plugins directory as PopMultiplier.AstroScript and restart astro. Change MultFactor to whatever you need, though I think it needs to result in an integer.

    This isn't thoroughly tested, so I'd make a backup of your current sector map just in case.

    #plugin Population Multiplier
    #author NBOS
    #desc   Multiplies the population of all bodies by a given factor
    
    MultFactor = 10 
    
    sector = GetCurrentSector()
    numberOfSystems = sector.SystemCount()
    
    For currentSystem = 1 to numberOfSystems 
        b = sector.GetSystem( currentSystem -1)
    
        sector.DynaLoad b
    
        UpdatePopulations b
    Next
    
    
    Function UpdatePopulations( b)
    
        If b.Population > 0 Then
            b.Population = b.Population * MultFactor
            b.Modified = true
            b.ModifySystem
        End If
    
        n = b.ChildrenCount()
        For i = 1 to n
            c = b.GetChild( i-1)
            UpdatePopulations c
        Next
    
    End Function
    
  • Thank you so much! This is definitely working on my end. I've made a backup just in case though.

Leave a Comment