Adding MegaStructures to every star system...

Hello Everyone, I'm looking for the easiest way to add three megastructures equidistant apart, always 300,000,000 miles from the star. I could add them at the DB level, but they would not get the GUID assigned like the existing ones that I have added manually. Any thoughts out there?

Comments

  • Hello Ed, any thoughts on this one?

  • Maybe put them in the same orbit at 3 different points along the orbit (use time past periapsis for positioning along orbit)

  • That is what I have been doing. Problem is that it is very time-consuming to add each of these manually. That is adding three megastructures per star system with 2756 Stars currently on the map. Each addition also means calculating the past periapsis so that they are equidistant from each other. Yes, this works, but I was hoping to get this project done before I die of old age, and I am already in my 60's. :-p

  • Was just looking for a way to automate this process. I like automation. I'm lazy. :-)

  • You could certainly write a script for it to add them in bulk. To get them relatively equadistant take the orbital time and divide it by 3. ie, if its a 300 day orbital period, make one at 0, one at 100, and one at 200. But they are elliptical orbits so the exact distance would vary over time.

  • I'm working on a script for that now. I was planning on putting them in a perfectly circular orbit. They are artificial in nature, so why have an eliptical orbit? I am going to try and avoid thinking about gravitational perturbations, whether than are mutual or n-body types. Although that would be a fun mental exercise, it really would not add to the storyline I am trying to build. ;-)

  • Yep, just set the eccentricity to 0 and it will be circular. Let me know if you have any q's.

  • I wanted to keep it simple, so I tried to script this to just add one megastructure around each star, but I keep getting VBScript errors. Something is wrong with the way I am trying to add the child to the star. I'm not a big VBScript guy, so maybe someone out there can help me out. I will try to add my script here:

    plugin Starlock Placement

    author Steven R. Hoag

    desc Puts a Starlock around every star in the sector.

    ' Set constants
    Const BODY_TYPE_MEGASTRUCTURE = 28 ' Corresponds to the AlienAPI body type for megastructures

    ' Function to add a "Starlock Facility" around a star
    Sub AddStarlockFacility(star)
    ' Create a new body (megastructure) as a child of the star
    Dim megastructure
    Set megastructure = star.AddChild(BODY_TYPE_MEGASTRUCTURE)

    ' Set properties of the megastructure
    megastructure.Name = "Starlock Facility"
    megastructure.PoliticalAffiliation = "Starlock Network"
    megastructure.Population = 1
    megastructure.Distance = 300000000 ' Distance in kilometers
    

    End Sub

    ' Main function to iterate over all stars in the sector and add a "Starlock Facility" to each
    Sub Main
    ' Retrieve the current sector
    Dim sector
    Set sector = GetCurrentSector()

    ' Get the total number of root bodies (star systems) in the sector
    Dim count, i
    count = sector.GetSectorBodyCount()
    
    ' Loop through each star in the sector
    For i = 0 To count - 1
        ' Retrieve the star system
        Dim star
        Set star = sector.GetRootBody(i)
    
        ' Add the "Starlock Facility" around the star
        AddStarlockFacility(star)
    Next
    

    End Sub

    ' Execute the main function
    Main

  • Sorry about the strange formatting. Should have pasted as plain text. Oops.

  • Try iterating systems like this

    #plugin  Squashdown!
    #author NBOS
    #desc       Compresses system positions along the Y axis
    
    sector = GetCurrentSector()
    j = sector.SystemCount
    For i = 1 to j 
        o = sector.GetSystem( i-1)
    
        o.y = o.y / 2
        o.Modified = true   
    
        If i mod 100 = 0 Then
            sector.RenderMessageBig = "Updating " & i & " of " & j
            RefreshScene
        End If
    
    Next
    sector.RenderMessageBig = ""
    RefreshScene
    

    Use SystemCount() and GetSystem() to retrieve the systems. Then add your megastructure to each. Keep in mind if you have binaries, you'll have to decide what you want to do for those.

  • Okay, I've re-written and simplified the script, but I am still getting the dreaded Microsoft VBScript runtime error. I believe the issue is with creating the child body, but maybe I am wrong.

    plugin Add Starlock to Non-Binary Systems

    author Steven R. Hoag

    desc Adds a Starlock Facility around each non-binary star system

    Set sector = GetCurrentSector()
    Dim sysCount
    sysCount = sector.SystemCount

    'Iterate through each system in the sector
    For i = 1 To sysCount
    Set starSystem = sector.GetSystem(i - 1)

    'Check if the system is non-binary (single star)
    If starSystem.BodyCount = 1 Then
        'Create a new megastructure (Starlock Facility) as a child body
        Set starlock = starSystem.CreateBody
        starlock.Name = "Starlock Facility"
        starlock.BodyType = BODY_TYPE_MEGASTRUCTURE
        starlock.PoliticalAffiliation = "Starlock Network"
        starlock.Population = 1
        starlock.Distance = 300000000
        starlock.Modified = True
    
        'Refresh the scene every 100 systems
        If i Mod 100 = 0 Then
            sector.RenderMessageBig = "Adding Starlock Facility: " & i & " of " & sysCount
            RefreshScene
        End If
    End If
    

    Next

    'Clear the update message
    sector.RenderMessageBig = ""
    RefreshScene

  • What's the error you're getting? Usually commenting out lines until the error goes away gets you the cause.

    You can check if the BodyType is BODY_TYPE_MULT or BODY_TYPE_CLOSEMULT to detect if its a multiple. Actually what you might want to do is the other way around - only add the object if its BODY_TYPE_STAR.

    After you create the body, you have to add it to the star using starsystem.AddChild( starlock)

  • "Microsoft VBScript runtime error"

    Not particularly helpful or informative.

  • I will try your latest suggestions and let you know if I get any further along. It may be a day or two as things at work are really busy.

Leave a Comment