Plugin Questions

I've playing around with a couple of plugins and modifying them for my needs.

I hit a couple of walls.

1) While a plugin is running, is there a way to flush the memory AS3 is using? I'm processing lots of data and get the "out of memory" message a lot.

2) I'm importing my own star data and running plugins to generate contents (see #1). I'm not a fan of either small bodies or space stations. I'm looking for code to cycle through the sector, find either of these types and delete them. I have scripts the cycle through my sector and generate contents, but can't figure out how to eliminate certain body types.


Thanks. Any help will be appreciated.

Comments

  • #1 - You can try saving the sector to file periodically, which will unload a lot of data.

    #2 - You can try generating a new sector first with the frequency for small bodies set all the way down. Those settings may carry over in the scripts.
  • Ed_NBOS wrote:
    #1 - You can try saving the sector to file periodically, which will unload a lot of data.

    #2 - You can try generating a new sector first with the frequency for small bodies set all the way down. Those settings may carry over in the scripts.

    Using "Save to File" worked wonders.

    No joy on #2. Is there a function to delete a body of a certain type?
  • I got a chunk of code that reassigns a space station to a temp star that gets deleted once the station has been moved. Stepping through each system's children and looking for stations, the code deletes the first two and then I get a runtime error. I'm thankful for any help.
    Sub DelStations(body)
    	'Delete Space Station
    
    	If body.ChildrenCount > 0 Then
    
    		For n = 1 To body.ChildrenCount()
    			Chi = body.GetChild(n-1)
    			If Chi.TypeID = BODY_TYPE_STATION Then
    				o = CreateBody("star")
    				o.x = 0
    				o.y = 0
    				o.z = 0
    				o.Name = "Temp Star"
    				sector.AddSystem o
    				RefreshScene
    
    				'Infomational Message
    				sector.RenderMessageSmall = "Processing System " & body.Name & "/" & Chi.Name & " --> " & o.Name
    				sector.ReassignChild Chi, o
    				RefreshScene
    				Pause 1000	'For debug
    				o.DeleteChildren()
    				sector.DeleteRootBody o
    				RefreshScene
    				Pause 1000 	'For debug
    			End If
    		Next
    
    	End If
    
    End Sub
    
  • Wow. This is ridiculous.

    Not only is there a total lack of documention within the Alien API docs, the lack of functions is laughable. Why is there an AddChild function but not a DeleteChild function? And I said delete child, I know I can delete all the children, but that's not what I'm after.

    Don't get me wrong, I love AS. But I guess AS isn't supposed to be for power users.
  • the code deletes the first two and then I get a runtime error.

    You're adding the body to two systems. When one gets deleted, there's a null pointer under the second one, hence the error.
  • Not only is there a total lack of documention within the Alien API docs, the lack of functions is laughable. Why is there an AddChild function but not a DeleteChild function? And I said delete child, I know I can delete all the children, but that's not what I'm after.

    The API is a hook into literally the exact classes and methods used by Astro. Not everything will be in there because some tasks done by the program require direct access to memory, which is not possible in a scripting language.

    Instead of doing all this in script, how about simply opening the file in sqlite and deleting the rows you dont want? It'd take a single sql statement to remove all space stations.
  • The SQL worked. Thanks Ed.

    I guess I can't see in my code where I was adding the child to a second system. Could you point it out to me?

Leave a Comment