Generate Sector Contents

What if you're using a real world star map and want to generate fictional child bodies for a huge number of stars? Worse, what if you don't want to have a huge, unweildy file afterwards?

First off, I know very little about plugins and scripting. A little reading has gotten me some clues, but it's not like I've written any.

What I need to do:
1. Go to a star or multiple in an existing sector.
2. Check to see if it is within parameters (for example, I am limiting my inhabited worlds to stars of stellar types F8 through G5. This should probably be selectable if anyone besides me wants to be able to use it). If not, cycle to the next star/multiple in the sector.
3. If it is within parameters, generate system contents.
4. If the generated system contains no bodies within parameters (in my case, Hospitable worlds), delete system contents. This keeps the number of total bodies down to manageable size while still following the "hospitable worlds are rare" convention.
5. Cycle to the next star in the sector and repeat.

This would allow random generation of contents for an already existing star map, consisting of dozens or hundreds of worlds spread out over hundreds of light years. If possible, another good feature would be to hide all bodies except those with habitable worlds *and those within X number of degrees of arc to a line drawn between habitable worlds.* This would allow for "outpost worlds" that serve little function other than as waypoints between the hospitable ones.

Any thoughts? Does something like this already exist and I just haven't spotted it?

Comments

  • The other thing I think is badly needed is for the sector generator to have the ability to infer starfield density from what you already have. So for example, you can take a 50ly radius chunk of star field from actual Hipparcos data or wherever that is centered a thousand ly away, and from the extremely bright stars you can see, infer a density of dim K's and M's that you *cannot* see from here and fill them in.

    If you could do this and the one I posted above, a pretty green user could import starfield data, create a "string of pearls" of sectors and subsectors that comprise dozens or hundreds of systems each, and hide the ones not germane to his current work, all with comparative ease I would think. And all extrapolating from what we actually see when we look up.

    Am I off the deep end here? Are there obvious answers I'm not seeing? Or has this already been done?
  • I'm willing to start teaching myself how to write plugins anyway, so let me ask this: What command accesses the "Delete System Contents" function inside AS? If I can find out that one, I can probably learn everything else I need to know from plugins that already exist.
  • To delete the contents of a system (meaning everything except the parent star / body), you can use the body class's DeleteChildren method.

    Assuming b is the root body:
    b.DeleteChildren()
    

    So something like this would delete all system contents, just leaving the parent (root) bodies on the map:
    sector = GetCurrentSector();
    n = sector.SystemCount
    For i = 1 to n
       b = sector.GetSystem( i-1)
       b.DeleteChildren()
    Next
    

    To delete the system itself, there's a DeleteRootBody() method in the Sector class.
    Something like this should delete all systems on the map:
    sector = GetCurrentSector();
    n = sector.SystemCount
    For i = 1 to n
       b = sector.GetSystem( i-1)
       b.DeleteRootBody( b)
    Next
    
  • To generate system contents themselves, you can do a couple things.

    There's a function called QuickGenerateSystemContentsKeepName() which is probably what you want. This will generate contents and not rename the root body (doesn't use organic naming). You pass it a body and true/false for whether or not you want populations.
    n = sector.SystemCount
    for i = 1 to n
       b = sector.GetSystem( i -1)
       if  <whatever conditions you want to apply> then
          QuickGenerateSystemContentsKeepName b, true
       end if
    next
    

    There's also a function called RandomSystem() with the same parameters, but that will wipe out the system and give you all new contents, possibly including names.
  • That looks like it will be useful to play with. There's only a couple of things I still have a question about, in terms of whether or not I can do what I need with those commands:
    ...you can use the body class's DeleteChildren method.

    What happens if the root body is a multiple or close multiple?

    And for whether they fall into particular parameters, can I use the same conventions the search function uses, such as "Spectral like F"? For example, how would I go about defining "If none of the children is Hospitable"?
  • If the root body Is a multiple star system, it will delete all the component stars and everything under them. If you don't want that behavior, you'll need to make a function in the script that iterates through the child objects in a multiple star system and deletes the children of the individual stars.

    You can't generally use the Natural Language Search system to search a specific body (you can, but it wouldn't be very efficient). You can use the NLS to search among a group of bodies (such as the entire sector) in code, and then have access to the results. So you could get a list of all bodies that don't have any hospitable planets among them, and then do your regenerations. That's the AstroSearcher Class.

    Word of warning... if the plan is to regenerate a system if there is no hospitable planet in it, some systems cannot support a hospitable planet, so you may not get one no matter how many times you try to run the generator.

    If you just want to look at specific stars, it may be easiest to look directly at the properties of their planets (gravity, population, etc). Look at the API doc for the list of properties and functions. For example, there is a GetMaxChildHabitability() method that can be called.
  • Look at the API doc for the list of properties and functions.

    I'd love to, but I don't know where it is.

    EDIT: Never mind, found it. Thanks!
  • Now I have a very different problem.

    I have a free VBS editor, so I can get the color coding to help make sense of a script, so long as I change the file extension to .vbs from .astroscript... but I don't see any way I can debug it. I mean yes, I can go through and look for errors, but I can't step through the script, see what it does, and where it fails. I can't run it from a command prompt because it requires AS data not available at a command prompt. I can run it in AS, but I can't see any way to go through it one step at a time for troublehooting purposes.

    Okay, what's the obvious answer that I'm missing? I figure there has to be an obvious answer, since I can't possibly be the first person who has wanted to step through an AS script for debugging purposes.
  • For application scripting like this, MsgBox is really your best friend. Astro and FM use Microsoft's Active Scripting system. While there is some debugging support in Active Scripting, I find that it usually causes more trouble than its worth (lockup, bizarre behavior). So for application level scripting like this, old school debugging works better I'm afraid.

    In your editor, you should be able to set it so that you can color code .AstroScript files rather than having to rename the extension each time.
  • Hi there GrumpyOldFart, :)

    Did you get anywhere with your efforts generating system contents for already placed stars? I'm looking to do something similar - I have several sectors of empty star systems which I want to populate automatically.

    Cheers!

    Sarah
  • Shaira wrote:
    Hi there GrumpyOldFart, :)

    Did you get anywhere with your efforts generating system contents for already placed stars?

    Sarah

    No, I didn't.

    Just a bit over 2 years ago, my mother's house burned to the ground, and she passed away a week later. My sister and I ended up spending the last 2 years fighting with various people who couldn't seem to understand the concept of "No, we don't have any records of _____, they were destroyed in a house fire." It took me nearly 6 months just to get the government to admit that I exist at all. Then there was probate... twice, and my sister building a new house on the land, and... well, let's just say that it was only about 3 months ago that I stopped effectively living out of a bug-out bag.

    Sorry, I got kinda distracted.

Leave a Comment