#plugin Mass Surface Map / Blazon Generator #author NBOS #desc Generates a surface map For the most populated planet in a system and Then assigns that as the system's blazon 'This example: '- Finds the most populated planet in a star system '- Generates a surface map for it '- And then assigns that surface map as the blazon image for the parent star ' 'This script is an example of how to '- iterate through all the systems on a sector map '- dynamically load & unload a system's child data from file '- generate a surface map via the FWE engine '- set blazon properties '- check to see if the Esc key was pressed (to cancel the script) ' ' On big maps it'll take a long time to generate all the surface maps, so ' you may want to just start it up and go get lunch! MaxPopBody = 0 DoSetSurfaceBlazon Sub DoSetSurfaceBlazon() sAstroPath = AstroDirectory() sector = GetCurrentSector() j = sector.SystemCount 'iterate through all the bodies on a map For i = 1 to j 'check if Esc key pressed nKey = GetKey() If nKey = 27 Then Exit For End If sector.RenderMessageBig = CStr( i) & " of " & CStr( j) RefreshScene o = sector.GetSystem( i-1) 'is it a space station? If o.TypeID = BODY_TYPE_STATION Then sector.SetBlazonImage o, sAstroPath & "\textures\BlazonImages\Ships\ShipBlazon12.png" o.BlazonDisplay = true o.BlazonWrap = false End If If o.TypeID <> BODY_TYPE_STATION Then bUnload = false If not o.Loaded Then bUnload = true sector.DynaLoad o End If MaxPopBody = o SetHighestSystemPop o If MaxPopBody.Population > 0 Then Sector.RenderMessageSmall = "Creating Surface Map for " & MaxPopBody.Name & ". Press Esc to cancel" RefreshScene 'generate the surface map If Len( o.PreviewImageFile) < 1 Then 'create a colorgroup object to use to tell the FWE engine what color settings we'll want 'and tell astro to derive a default set of colors 'these colors, of course, could be altered via the script as well fc = DefaultAstroColorGroup() DerivePlanetColors o, fc 'make the map ProcessMessages b = GenerateFWESurfaceMap( sector, MaxPopBody, false, fc) 'free the color group object from memory FreeObject fc End If 'get the name of the surface map we just made (ie, the preview image) and 'assign it as the blazon for the parent star sFile = MaxPopBody.PreviewImageFile sector.SetBlazonImage o, sFile o.BlazonDisplay = true o.BlazonWrap = true 'dont dynaunload Sector.RenderMessageSmall = "" Else o.BlazonDisplay = false o.BlazonWrap = false 'nothing changed, so unload it if it was loaded If bUnload Then sector.DynaUnload o End If End If End If Next sector.RenderMessageBig = "" RefreshScene End Sub 'recursively finds the highest populated body in a system Sub SetHighestSystemPop( b) n = b.ChildrenCount() For k = 1 to n c = b.GetChild(k-1) If c.TypeID = 100 Then If c.Population > MaxPopBody.Population Then MaxPopBody = c End If End If SetHighestSystemPop( c) Next End Sub