Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.9.1a is out! (05/10/19); Blog post: Painting the Stars (02/07/20)

Author Topic: API reference  (Read 3484 times)

Ghoti

  • Captain
  • ****
  • Posts: 283
    • View Profile
    • Email
API reference
« 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?
Logged

TJJ

  • Admiral
  • *****
  • Posts: 1839
    • View Profile
    • Email
Re: API reference
« Reply #1 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.
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1291
    • View Profile
    • GitHub Profile
Re: API reference
« Reply #2 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. :)
Logged

Ghoti

  • Captain
  • ****
  • Posts: 283
    • View Profile
    • Email
Re: API reference
« Reply #3 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.
« Last Edit: September 07, 2012, 06:15:40 AM by Ghoti »
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1291
    • View Profile
    • GitHub Profile
Re: API reference
« Reply #4 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.
Logged

Ghoti

  • Captain
  • ****
  • Posts: 283
    • View Profile
    • Email
Re: API reference
« Reply #5 on: September 07, 2012, 06:11:22 AM »

...
*squints*

LAZY
LAZY wizard
OK.
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1291
    • View Profile
    • GitHub Profile
Re: API reference
« Reply #6 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. :)
Logged

Ghoti

  • Captain
  • ****
  • Posts: 283
    • View Profile
    • Email
Re: API reference
« Reply #7 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.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 4854
  • naively breaking things!
    • View Profile
Re: API reference
« Reply #8 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? 
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Trylobot

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1168
    • View Profile
    • Github profile
Re: API reference
« Reply #9 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.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 4854
  • naively breaking things!
    • View Profile
Re: API reference
« Reply #10 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 :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Ghoti

  • Captain
  • ****
  • Posts: 283
    • View Profile
    • Email
Re: API reference
« Reply #11 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*
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1291
    • View Profile
    • GitHub Profile
Re: API reference
« Reply #12 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).
« Last Edit: September 09, 2012, 04:40:42 AM by LazyWizard »
Logged