It looks like you're new here. If you want to get involved, click one of these buttons!
#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 Max = 100 Count = 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 'is it a fleet? If o.TypeID = BODY_TYPE_FLEET Then sector.SetBlazonImage o, sAstroPath & "\textures\BlazonImages\Ships\FleetBlazon.png" o.BlazonDisplay = true o.BlazonWrap = false End If If o.TypeID <> BODY_TYPE_STATION AND o.TypeID <> BODY_TYPE_FLEET Then bUnload = false If not o.Loaded Then bUnload = true sector.DynaLoad o End If MaxPopBody = o SetHighestSystemPop o FractalMap o, sector If MaxPopBody.Population > 0 Then '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 End If End If If Count > Max Then Exit For End If Next sector.RenderMessageBig = "" RefreshScene End Sub 'recursively generate each Sub FractalMap( b, sector) n = b.ChildrenCount() For k = 1 to n c = b.GetChild(k-1) Sector.RenderMessageSmall = "Creating Surface Map for " & c.Name & " in system " & b.Name & ". Press Esc to cancel" RefreshScene If Count > Max Then Exit For End If 'generate the surface map If Len( c.PreviewImageFile) < 1 And c.TypeID <> BODY_TYPE_STATION And c.TypeID <> BODY_TYPE_FLEET And c.TypeID <> BODY_TYPE_PLANETOID And c.TypeID <> BODY_TYPE_ASTEROIDBELT And c.TypeID <> BODY_TYPE_MEGASTRUCTURE And c.TypeID <> BODY_TYPE_SHIP 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 c, fc 'make the map ProcessMessages z = GenerateFWESurfaceMap( sector, c, false, fc) 'free the color group object from memory FreeObject fc Count = Count + 1 End If FractalMap c, sector Next Sector.RenderMessageSmall = "" 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
Comments
From your code it looks like you aren't flagging the system as being modified, this will cause the problem of disappearing systems. After I make any changes to a system I do an UpdateRootBody and ModifySystem on the system object.
Here is an example from my usual template.
The sector object has a SaveToFile method that you could use to have it save every 100 systems or whatever. In theory this should free up the memory being used by AS but I've never played around with it so I don't know if it has any little idiosyncrasies.
Also to speed up the time it takes to run don't do a RefreshScene on every object because it will take forever on large maps. I discovered this when I was writing my Jump Route plugin. I had it doing a RefreshScene on each system as I looped though them and it took several hours to run, after taking it out of the loop it ran almost instantly.
Best Regards,
Alan Bartholet