Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Anubis-class Cruiser (12/20/24)

Author Topic: Trade Info Mod  (Read 1979 times)

Not_a_cat

  • Ensign
  • *
  • Posts: 40
    • View Profile
Trade Info Mod
« on: February 08, 2024, 02:46:00 AM »

Most of my money I get in Starsector comes from the trade, however it's quite annoying to operate given that you have to manually look into each commodity to figure out the best trade route. So I would like to work on the mod which will add trading quests* to the separate trading tab within intel window. I am surprised it hasn't been done yet, -- or did I just fail to find this mod? Or is this impossible to implement for some reason?

* By trading quests I mean automatically generated / updated indicators of deficit / excess of every commodity which will be displayed on the map as a mission
« Last Edit: February 08, 2024, 03:15:31 AM by Not_a_cat »
Logged

Dazs

  • Admiral
  • *****
  • Posts: 1201
    • View Profile
Re: Trade Info Mod
« Reply #1 on: February 08, 2024, 04:48:54 AM »

The closest I know of is Space Truckin' https://fractalsoftworks.com/forum/index.php?topic=24169.0 but cptdash has not updated it to .97a yet. I believe it generates it supply/demand outside of the base economy though so it may not be what you are looking for.

Not_a_cat

  • Ensign
  • *
  • Posts: 40
    • View Profile
Re: Trade Info Mod
« Reply #2 on: February 08, 2024, 05:40:55 AM »

TY ! Will take a look
Logged

Not_a_cat

  • Ensign
  • *
  • Posts: 40
    • View Profile
Re: Trade Info Mod
« Reply #3 on: February 17, 2024, 02:11:28 AM »

Hi everyone I've started working on trading mod and struggle with TooltipMakerApi a bit.
I am trying to add mission icon (stolen from nexerilin mod):

Code
    @Override
    public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
        float opad = 10f;
        info.addImage("graphics/icons/rem_salvation.png", width, height, opad);
        info.addPara("In Jangala there is " + getName(), opad);
        info.addPara(Misc.getAgoStringForTimestamp(timestamp) + ".", opad);
    }
Which exist in the project


However it never shown.

What am I doing wrong?
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4913
    • View Profile
    • GitHub profile
Re: Trade Info Mod
« Reply #4 on: February 18, 2024, 07:09:47 AM »

Image files aren't loaded by the game unless they're specified in a file that uses them (things like ship sprite in the .ship file, or commodity icon in commodities.csv). You can force an image to load using the graphics section of settings.json, or by calling Global.getSettings().loadTexture in your code.
Logged

Not_a_cat

  • Ensign
  • *
  • Posts: 40
    • View Profile
Re: Trade Info Mod
« Reply #5 on: February 18, 2024, 08:31:54 AM »

Thanks !
Logged

Not_a_cat

  • Ensign
  • *
  • Posts: 40
    • View Profile
Re: Trade Info Mod
« Reply #6 on: February 21, 2024, 04:54:06 AM »

[deleted]
« Last Edit: February 21, 2024, 04:56:51 AM by Not_a_cat »
Logged

Not_a_cat

  • Ensign
  • *
  • Posts: 40
    • View Profile
Re: Trade Info Mod
« Reply #7 on: February 21, 2024, 04:55:26 AM »

Dear modders I got trading mod to work (more or less) however I do not get how to get deficit / abundance here is how I do it currently:

Code
for (LocationAPI marketLocation : marketLocations) {
    for (MarketAPI market : Global.getSector().getEconomy().getMarkets(marketLocation)) {
        float price = market.getDemandPrice(commodityId, 1.0, false);
        float demand = market.getDemand(commodityId).getDemandValue();

        if (commoditySpecAPI.getBasePrice() * 1.4 < price) {
            Global.getSector().getIntelManager().addIntel(
                new CommodityDeficitIntel(market.getPrimaryEntity(), commodityId, (int) demand, (int) price));
        }
        break;
    }
}

What would be the correct way to get the pair (price, deficit) preferably the same numbers as shown in commodity info window
Logged

Hexxod

  • Ensign
  • *
  • Posts: 44
    • View Profile
Re: Trade Info Mod
« Reply #8 on: February 22, 2024, 05:37:55 PM »

Sounds a lot like what Stellar Networks does. Does a bit more than you were looking for, but Jaghaimo did open source his stuff - Maybe spin off your own version?

https://fractalsoftworks.com/forum/index.php?topic=20836.0
Logged

Not_a_cat

  • Ensign
  • *
  • Posts: 40
    • View Profile
Re: Trade Info Mod
« Reply #9 on: February 23, 2024, 06:17:22 AM »

Will take a look thx
Logged