How to Duplicate a star system

I am looking to duplicate a star system exactly like one that already exists, how can I do this?

Thank you.

Comments

  • I made a script that you can use to do this. It will duplicate selected systems. Save it as CloneSelected.AstroScript in the /Plugins directory. Restart Astro, and it should be in the Plugins menu.

    Cloning a system is fairly easy in the API, but the trick is the unique ID string also needs to be updated so that there's no collisions between the original and new copy. Source listed below for the curious, but its also down below as an attachment.

    #plugin     Clone Selected
    #author     NBOS
    #desc       Clones/duplicates the selected systems
    
    Dim b, j, i, sector
    
    Randomize
    
    sector = GetCurrentSector()
    j = sector.SelectedCount()
    
    For i = 1 to j 
        b = sector.GetSelected(i-1)
        If not b.Loaded Then
            sector.DynaLoad( b)
        End If 
    
        CloneBody( b)
    Next 
    
    
    Sub CloneBody( o)
        Dim c
        c = CreateBody("")
        o.CopyTo( c)
        RegenUABI( c)
        c.x = c.x + 0.5 'shift it over to make it selectable
        c.y = c.y + 0.5
        c.z = c.z + 0.5
        c.Selected = false
    
        sector.AddSystem( c)
        c.ModifySystem()
    
    End Sub
    
    'Generates Unique ID strings for the new cloned bodies
    Sub RegenUABI( o)
        Dim c, i
    
        newid = NewUABI()
        o.IDString = newid
    
        n = o.ChildrenCount()
        For i = 1 to n 
            c = o.GetChild( i-1)
            RegenUABI( c)
        Next
    End Sub
    
    Function NewUABI
       NewUABI = "{" & RandStr(8) & "-" & RandStr(4) & "-" & RandStr(4) & "-" & RandStr(4) & "-" & RandStr(12) & "}"
    End Function
    
    Function RandStr( n)
        Dim i, c, v
        c = "0123456789ABCDEF"
        RandStr = ""
        For i = 1 to n
            v  = Round( (Rnd() * 16)) + 1
            RandStr = RandStr & Mid( c, v, 1)
        Next
    End Function
    
  • Thank you very much Ed!

  • One last question for this Ed,

    Are both systems in the EXACT same location of space? IE X Y & Z locations or is there a slight difference?

    Thank you
    Lee

  • Hi Lee, it shifts them half a light year so they'll be selectable after they are cloned. If you don't want that, you can comment out the shift in the CloneBody function, or change it to whatever value you'd like.

Leave a Comment