#plugin Big Bang V1.5 Beta 3 #author Exile In Paradise, Jeff Parker, Ed Diana - 20060714 21:46 #desc Create random star systems with surface maps for each star in a sector. cancelled = False SaveToDiskCount = 100 ' Number of bodies to process before saving the data to the hard drive NumberOfBodiesProcessed = 0 SystemInProcess = 0 sector = GetCurrentSector() numberOfSystems = sector.SystemCount() ScanSystems RefreshScene Sub ScanSystems sector.RenderMessageBig = CStr(numberOfSystems) & " systems found. Hit [ESC] to cancel and [P] to pause processing." RefreshScene DisplayUpdate = 1 ' Number of systems to process before updating the display for currentSystem = 1 to numberOfSystems SystemInProcess = currentSystem If ((currentSystem Mod DisplayUpdate) = 0) Then sector.RenderMessageBig = CStr(numberOfSystems) & " systems found - " & currentSystem & " systems processed (" & CInt((currentSystem/numberOfSystems) * 100) & "%). Hit [ESC] to cancel and [P] to pause processing.." RefreshScene End If ProcessSystem(currentSystem - 1) NumberOfBodiesProcessed = NumberOfBodiesProcessed + 1 If ((NumberOfBodiesProcessed Mod SaveToDiskCount) = 0) Then Sector.SaveToFile Sector.FileName, false End If If (cancelled) Then Exit Sub Next Sector.SaveToFile Sector.FileName, false sector.UpdateVisibleCount RefreshScene End Sub Sub ProcessSystem( systemNumber ) 'check for a cancel CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused aSystem = sector.GetSystem(systemNumber) If not aSystem.Loaded Then sector.DynaLoad aSystem End If RegenerateSystem aSystem If (cancelled) Then Exit Sub ProcessPlanetaryBodies aSystem If (cancelled) Then Exit Sub 'do this so that astro can keep track of things like populations & political affiliations more efficiently If (sector.Modified = True) Then aSystem.UpdateRootBody End If End Sub Sub RegenerateSystem( aSystem ) 'check for a cancel CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused temp = aSystem.Name ' save name aSystem.ClearFields RandomSystem aSystem, true 'use built-in astro generator, w/ populations aSystem.Name = temp 'restore name End Sub Sub ProcessPlanetaryBodies( aSystem ) 'check for a cancel CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused If (aSystem.ChildrenCount() = 0) Then Exit Sub For currentBody = 1 to aSystem.ChildrenCount() ProcessChildBody aSystem, currentBody - 1 If (cancelled) Then Exit Sub NumberOfBodiesProcessed = NumberOfBodiesProcessed + 1 If ((NumberOfBodiesProcessed Mod SaveToDiskCount) = 0) Then Sector.SaveToFile Sector.FileName, false End If Next 'if system is populated, change the label color if aSystem.ChildPopulation > 0 then aSystem.LabelColor = rgb( 128, 255, 0) end if End Sub Sub ProcessChildBody( aSystem, bodyNumber ) 'check for a cancel CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused aBody = aSystem.GetChild(bodyNumber) if aBody.TypeID = BODY_TYPE_TERRESTRIAL or aBody.TypeID = BODY_TYPE_GASGIANT or aBody.TypeID = BODY_TYPE_PLANETSYSTEM then MakeMaps(aBody) End If End Sub Sub MakeMaps( aBody ) 'check for a cancel CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused ProcessMessages ProcessBody aBody If (cancelled) Then Exit Sub For currentBody = 1 to aBody.ChildrenCount() MakeMaps(aBody.getChild(currentBody-1)) If (cancelled) Then Exit Sub NumberOfBodiesProcessed = NumberOfBodiesProcessed + 1 If ((NumberOfBodiesProcessed Mod SaveToDiskCount) = 0) Then Sector.SaveToFile Sector.FileName, false End If Next End Sub Sub ProcessBody( aBody ) 'check for a cancel CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused Select Case aBody.TypeID Case BODY_TYPE_TERRESTRIAL 'only generate one if nothings there now If Len( aBody.PreviewImageFile) < 1 Then ProcessMessages GenerateSurfaceMap aBody CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused aBody.UpdateRootBody If sector.Modified = false then sector.Modified = true End If End If Case BODY_TYPE_GASGIANT 'only generate one if nothings there now If Len( aBody.PreviewImageFile) < 1 Then ProcessMessages GenerateGasGiantAtmTexture Sector, aBody, 512, 256 CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused aBody.UpdateRootBody If sector.Modified = false then sector.Modified = true End If End If End Select End Sub Sub GenerateSurfaceMap( aBody ) 'check for a cancel CheckIfCancelled If (cancelled) Then Exit Sub CheckIfPaused '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 aBody, fc 'make the map bodyMap = GenerateFWESurfaceMap( sector, aBody, false, fc) 'free the color group object from memory FreeObject fc End Sub Sub CheckIfCancelled If (cancelled = False) Then cancelled = (GetKey() = 27) End If End Sub sub CheckIfPaused If ((GetKey() = 80) Or (GetKey() = 112)) Then sector.RenderMessageBig = "Processing paused. Hit [P] to continue processing. Paused on system number " & SystemInProcess RefreshScene KeyPressed = GetKey() Do While (KeyPressed <> 80) And (KeyPressed <> 112) Pause 500 KeyPressed = GetKey() Loop sector.RenderMessageBig = CStr(numberOfSystems) & " systems found - " & SystemInProcess & " systems processed (" & CInt((SystemInProcess/numberOfSystems) * 100) & "%). Hit [ESC] to cancel and [P] to pause processing.." RefreshScene End If End Sub