Plugin Questions

A place to discuss, announce, and request plug-ins and scripts

Plugin Questions

Postby brothercool » Mon Jun 25, 2012 4:30 pm

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.
brothercool
Torch Bearer
 
Posts: 18
Joined: Fri Oct 01, 2010 3:00 pm

Re: Plugin Questions

Postby Ed_NBOS » Tue Jun 26, 2012 2:14 am

#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
Site Admin
 
Posts: 523
Joined: Wed Jul 08, 2009 12:16 am

Re: Plugin Questions

Postby brothercool » Wed Jun 27, 2012 10:11 am

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?
brothercool
Torch Bearer
 
Posts: 18
Joined: Fri Oct 01, 2010 3:00 pm

Re: Plugin Questions

Postby brothercool » Thu Jun 28, 2012 9:26 pm

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.

Code: Select all
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
brothercool
Torch Bearer
 
Posts: 18
Joined: Fri Oct 01, 2010 3:00 pm

Re: Plugin Questions

Postby brothercool » Fri Jun 29, 2012 10:13 am

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.
brothercool
Torch Bearer
 
Posts: 18
Joined: Fri Oct 01, 2010 3:00 pm

Re: Plugin Questions

Postby Ed_NBOS » Fri Jun 29, 2012 3:42 pm

brothercool wrote: 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.
Ed_NBOS
Site Admin
 
Posts: 523
Joined: Wed Jul 08, 2009 12:16 am

Re: Plugin Questions

Postby Ed_NBOS » Fri Jun 29, 2012 3:48 pm

brothercool wrote: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.
Ed_NBOS
Site Admin
 
Posts: 523
Joined: Wed Jul 08, 2009 12:16 am

Re: Plugin Questions

Postby brothercool » Thu Jul 05, 2012 10:08 pm

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?
brothercool
Torch Bearer
 
Posts: 18
Joined: Fri Oct 01, 2010 3:00 pm


Return to AstroSynthesis Plug-ins and Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron