API Tutorials

Are there any guides to the Astrosynthesis API language? I've tried looking before... I'm especially interested in editing the parameters of the bulk 2D export script in this forum to show all stars within a certain radius of stars of a certain spectral class. I've used a certain type to set up a grid for a very large map--which I've finally completed after about six months--and would like to adapt the bulk export script to run off all of the "grid squares" formed by these specially designated stars.

I really appreciate the help. The sooner I can get this aspect done, the sooner I can work on the other aspects of the project. :D

Comments

  • Okay, so I looked through the script again and found the the API index posted at the top of the forum :p (sorry about missing that when I posted the thread). So, like I said, I'm trying to adapt the Bulk 2D Export script to work off a grid made up of red dwarf markers.

    Here is what I came up with after reading the original file and the API guide.
    #plugin      Export 2D maps
        #author      NBOS
        #desc         Exports a 2d map for specified systems
    
        'exports a 2D map for each populated system greater than PopLimit,
        'displaying all systems within a selected distance of the populated system.
    
        sector = GetCurrentSector()
    
        'Settings
    
        'be careful with this number on large sectors - it may
        'result in thousands of images getting generated!
        TargSpec = M9           'population cutoff for generating images
        ExpLimit = 450                 'maximum number of images to output, so it doesnt run all night
        MapDistance = 50               'distance, in light years, from center body that the map shows
        MapShape = 0                  'cube or sphere selection.  The shape to use when selecting bodies around
                                      'the center system.  Only affects body selection, *not* image shape.
                                      '1 = sphere, 0 = cube
    
        'image options
    
        SavePath = "C:\[insert directory here]\"      'where to save files to, make sure has ending \
        ColorMode = 2                 '0 = black & white, 1 = color on white, 2 = full color
        ShowRoutes = true              'whether to show routes or not
        ScaleZ = true                 'whether to scale system indicators based on their +/- Z coordinate
        ShowGrids = false              'whether to show grids or not
        FontScale = 6                 'font scale factor.  amount to multiply the font size by, can be decimal like 1.5
        SystemScale = 1                 'system scale factor. amount to multiple circle for system marker, can be decimal
        ImageSize = 4000               'width & height, in pixels, of generated image
        Orientation = 1                 'axis orientation, 0 = x/y, 1 = x/z, 2 = y/z
    
        'Do the image generation
        ExpCount = 0
        n = sector.SystemCount
        For i = 1 to n
           
           sector.selectall false
           
           b = sector.GetSystem( i-1)
    
           If (b.Visible) and (b.Spectral = TargSpec) Then
    
              'info display
              sector.RenderMessageBig = "Exporting 2D Maps"
              sector.RenderMessageSmall = CStr(i) & " / " & CStr(n)
              RefreshScene
    
              'create a new sector object, export to it a 10ly submap of main sector, export the new sector,
              'and then free it
              sector.selectbody b
              expsector = CreateSector()
              sector.CreateSubmapFromSelected expsector, MapDistance, MapShape
              
              expsector.Export2D SavePath & b.Name & ".png", ColorMode, ShowRoutes, ScaleZ, ShowGrids, FontScale, SystemScale, ImageSize, Orientation
              FreeObject expsector
              
              ExpCount = ExpCount + 1
              
           End If
           
           If ExpCount > ExpLimit Then Exit For
           
        Next
    
        RefreshScene
    

    It should create approximately 450 images, each centered on one of these red dwarf markers (they're the only M9s on the map... it's not a very astronomically-sound map, but what do you want from Star Wars?) and extending 50 LY in each direction in a cubic map.

    Unfortunately, when I attempt to Run From File, I get a "Script Error: Microsoft VBScript compilation error" dialog box and no enormous flood of images. Did I fumble something somewhere?

Leave a Comment