Fractal Softworks Forum

Starsector => Mods => Modding => Topic started by: Ghoti on September 07, 2012, 12:51:10 AM

Title: API reference
Post by: Ghoti on September 07, 2012, 12:51:10 AM
It would be nice to at least be able to see what functions we do or don't have access to. I mean there's this: http://fractalsoftworks.com/starfarer.api/
looks auto generated. Can we get more? This was really handy when developing missions.

A list of function signatures, and definitions for enumerated constants, would be more than enough.

I mean sure, we have the starfarer-core scripts, but do those in aggregate use every aspect of the API's?
Title: Re: API reference
Post by: TJJ on September 07, 2012, 01:18:07 AM
Yes, that's the output generated by javadoc.
If you install the jdk you can run it yourself and generate javadoc for all the java source files that accompany the game.
Title: Re: API reference
Post by: LazyWizard on September 07, 2012, 01:57:14 AM
It would be nice to at least be able to see what functions we do or don't have access to. I mean there's this: http://fractalsoftworks.com/starfarer.api/
looks auto generated. Can we get more? This was really handy when developing missions.

A list of function signatures, and definitions for enumerated constants, would be more than enough.

I mean sure, we have the starfarer-core scripts, but do those in aggregate use every aspect of the API's?

You can find the entire API source in starfarer-core/starfarer.api.zip. :)
Title: Re: API reference
Post by: Ghoti on September 07, 2012, 05:37:14 AM
You can find the entire API source in starfarer-core/starfarer.api.zip. :)

You are one fine Wizard, Lazy.
Holy crap.
Title: Re: API reference
Post by: LazyWizard on September 07, 2012, 06:04:05 AM
You can find the entire API source in starfarer-core/starfarer.api.zip. :)

You are one fine Wizard, Lady.
Holy crap.

What.
Title: Re: API reference
Post by: Ghoti on September 07, 2012, 06:11:22 AM
...
*squints*

LAZY
LAZY wizard
OK.
Title: Re: API reference
Post by: LazyWizard on September 07, 2012, 06:22:15 AM
;D

Anyway, many of the methods in the API aren't commented. If you need help with anything, feel free to ask. :)
Title: Re: API reference
Post by: Ghoti on September 07, 2012, 06:31:49 AM
way more than enough. I was browsing through mods to find references. I kept running across stuff like this:
Code
//Calc Supplies
    while (playerStorageCargo.removeItems(CargoAPI.CargoItemType.RESOURCES, "supplies", 1)) {
    totalSupplies = totalSupplies + 1;
    }

    //Return resources
    playerStorageCargo.addItems(CargoAPI.CargoItemType.RESOURCES, "supplies", totalSupplies);
and was having panic attacks.
Title: Re: API reference
Post by: xenoargh on September 07, 2012, 06:40:22 AM
Alex, if  you happen by and read this:  is http://fractalsoftworks.com/starfarer.api/ being auto-updated when new commits are pushed? 
Title: Re: API reference
Post by: Trylobot on September 07, 2012, 08:54:44 AM
It looks like it's not, xeno. I'll nudge Alex to post updated docs for those that wish to browse the API in this way.
Title: Re: API reference
Post by: xenoargh on September 08, 2012, 07:08:58 PM
It'd be cool if it was pushed into that process after commits, it really would be useful to know what's new in the API even if it's just through automation rather than some formal documentation, given that the big commits are quite likely to break stuff left, right and center for some time to come :)
Title: Re: API reference
Post by: Ghoti on September 08, 2012, 10:19:46 PM
OK so I was browsing the API reference, and I noticed that .addMothballedShip() is deprecated.
With a comment saying: * Use Global.getFactory().createFleetMember() and CargoAPI.getMothballedShips().addFleetMember() instead.

So instead of:
Code
GDcargo.addMothballedShip(FleetMemberType.FIGHTER_WING, "gedune_chua_wing");
we go:
Code
GDcargo.getMothballedShips().addFleetMember(Global.getFactory().createFleetMember(FleetMemberType.FIGHTER_WING, "gedune_chua_wing"));
or more concisely for multiple members:
Code
      FactoryAPI fac = Global.getFactory();
      FleetDataAPI GDmoths = GDcargo.getMothballedShips();
      GDmoths.addFleetMember(fac.createFleetMember(FleetMemberType.FIGHTER_WING, "gedune_chua_wing"));
right?

...
*twitch*
Title: Re: API reference
Post by: LazyWizard on September 09, 2012, 04:23:22 AM
Yeah it looks awkward, but addMothballedShip() predates FleetDataAPI and createFleetMember() and isn't nearly as versatile. The new system allows you to grab, analyse and customize the ship object before passing it in. :)

And you can still use addMothballedShip() for now if you want the simpler syntax (although I don't know if Alex plans to remove deprecated methods at some later date).