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: [HELP] Having trouble creating a star system{has been solved}  (Read 1775 times)

cess183

  • Ensign
  • *
  • Posts: 6
    • View Profile
[HELP] Having trouble creating a star system{has been solved}
« on: August 28, 2022, 03:10:03 PM »

I'm a beginner. I was trying to creat one star system. When the game try to generate the sector it crahs(that is after choosing the begining).

Here is the log
   
Spoiler
28617 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerExceptionjava.lang.NullPointerException
   at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
   at com.fs.starfarer.combat.entities.terrain.Planet.<init>(Unknown Source)
   at com.fs.starfarer.campaign.CampaignPlanet.<init>(Unknown Source)
   at com.fs.starfarer.campaign.StarSystem.initStar(Unknown Source)
   at com.fs.starfarer.campaign.StarSystem.initStar(Unknown Source)
   at data.scripts.world.systems.SystemAlpha.generate(SystemAlpha.java:28)
   at data.scripts.world.CEGen.generate(CEGen.java:82)
   at data.scripts.CEModPlugin.onNewGame(CEModPlugin.java:14)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.N.dismiss(Unknown Source)
   at com.fs.starfarer.ui.newui.do.dismiss(Unknown Source)
   at com.fs.starfarer.ui.newui.o0Oo.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.Q.advance(Unknown Source)
   at com.fs.starfarer.ui.v.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.Q.advance(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]

And this is the Modplugin
Spoiler
package data.scripts;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;

import data.scripts.world.CEGen;
import exerelin.campaign.SectorManager;

public class CEModPlugin extends BaseModPlugin {
   
    @Override
    public void onNewGame(){
    boolean haveNexerelin = Global.getSettings().getModManager().isModEnabled("nexerelin");
   if (!haveNexerelin || SectorManager.getManager().getCorvusMode()){
            new CEGen().generate(Global.getSector());
        }
    }
   
}
[close]

This is my gen file
Spoiler
package data.scripts.world;

import java.util.ArrayList;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.econ.EconomyAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;

import data.scripts.world.systems.SystemAlpha;



public class CEGen implements SectorGeneratorPlugin{


    //Shorthand function for adding a market
    //(I stole this from vic, it might is a good idea to creat methods that could help during the codding)
    public static MarketAPI addMarketplace(String factionID, SectorEntityToken primaryEntity, ArrayList<SectorEntityToken> connectedEntities,
                                        String name,int size, ArrayList<String> marketConditions, ArrayList<String> submarkets,
                                        ArrayList<String> industries,
                                        float tarrif, boolean freePort, boolean withJunkAndChatter) {
                                           
        EconomyAPI globalEconomy = Global.getSector().getEconomy();
        String planetID = primaryEntity.getId();
        String marketID = planetID + "_market";

        MarketAPI newMarket = Global.getFactory().createMarket(marketID, name, size);
        newMarket.setFactionId(factionID);
        newMarket.setPrimaryEntity(primaryEntity);
        newMarket.getTariff().modifyFlat("generator", tarrif);

        //Adds submarkets
        if (null != submarkets) {
            for (String market : submarkets) {
                newMarket.addSubmarket(market);
            }
        }

        //Adds market conditions
        for (String condition : marketConditions) {
            newMarket.addCondition(condition);
        }

        //Add market industries
        for (String industry : industries) {
            newMarket.addIndustry(industry);
        }

        //Sets us to a free port, if we should
        newMarket.setFreePort(freePort);

        //Adds our connected entities, if any
        if (null != connectedEntities) {
            for (SectorEntityToken entity : connectedEntities) {
                newMarket.getConnectedEntities().add(entity);
            }
        }

        globalEconomy.addMarket(newMarket, withJunkAndChatter);
        primaryEntity.setMarket(newMarket);
        primaryEntity.setFaction(factionID);

        if (null != connectedEntities) {
            for (SectorEntityToken entity : connectedEntities) {
                entity.setMarket(newMarket);
                entity.setFaction(factionID);
            }
        }

        //Finally, return the newly-generated market
        return newMarket;
    }

   
    //actual override part
    @Override
    public void generate(SectorAPI sector) {

        new SystemAlpha().generate(sector);

    }
}
[close]

And this is my star system's file
Spoiler
package data.scripts.world.systems;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.JumpPointAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.impl.campaign.ids.Conditions;
import com.fs.starfarer.api.impl.campaign.ids.Industries;
import com.fs.starfarer.api.impl.campaign.ids.Submarkets;
import com.fs.starfarer.api.util.Misc;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;

import data.scripts.world.CEGen;

public class SystemAlpha {

    public void generate(SectorAPI sector) {

        StarSystemAPI system = sector.createStarSystem("SystemAlpha");
        system.getLocation().set(1750,-1500);
        system.setBackgroundTextureFilename("graphics/backgrounds/background_alpha.jpg");

        PlanetAPI Applew = system.initStar(
            "ce_systemalpha_applew",
            "star_yellow",
            1000f,
            300f
        );
        system.setLightColor(new Color(255, 199, 98));


        PlanetAPI Colonia = system.addPlanet("ce_colonia", Applew, "Colonia", "arid",
            250, //start degree
            200, //radius
            5000, //distance
            30);//time to fully orbit
       
        MarketAPI Colonia_market = CEGen.addMarketplace(
            "independent",
            Colonia,
            null,
            "Colonia",
            5,

            new ArrayList<>(
                 Arrays.asList(
                    Conditions.POPULATION_5,
                    Conditions.DECIVILIZED_SUBPOP,
                    Conditions.HABITABLE,
                    Conditions.RUINS_SCATTERED,
                    Conditions.HOT,
                    Conditions.FARMLAND_ADEQUATE,
                    Conditions.ORE_SPARSE,
                    Conditions.RARE_ORE_MODERATE,
                    Conditions.ORGANICS_PLENTIFUL

                    )
                ),
            new ArrayList<>(
                Arrays.asList(
                    Submarkets.SUBMARKET_OPEN,
                    Submarkets.SUBMARKET_STORAGE,
                    Submarkets.SUBMARKET_BLACK
                    )
                ),
            new ArrayList<>(
                Arrays.asList(
                    Industries.STARFORTRESS_HIGH,
                    Industries.LIGHTINDUSTRY,
                    Industries.HEAVYBATTERIES,
                    Industries.MEGAPORT,
                    Industries.MINING,
                    Industries.PATROLHQ,
                    Industries.POPULATION,
                    Industries.WAYSTATION,
                    Industries.PLANETARYSHIELD,
                    Industries.FARMING,
                    Industries.TAG_IMPORTANT
                )
            ),
            0.13f,
            true,
            true
        );
       

        PlanetAPI Coupler = system.addPlanet("ce_coupler", Applew, "Coupler", "barren-bombarded",
        180,//start angle
        150,//radius
        2200,//distance
        49);//cycle time

        MarketAPI Coupler_market = CEGen.addMarketplace(
            "independent",
            Coupler,
            null,
            "Coupler",
            6,

            new ArrayList<>(
                Arrays.asList(
                    Conditions.POPULATION_6,
                    Conditions.NO_ATMOSPHERE,
                    Conditions.ORE_MODERATE,
                    Conditions.RARE_ORE_ULTRARICH,
                    Conditions.AI_CORE_ADMIN,
                    Conditions.VERY_HOT,
                    Conditions.LOW_GRAVITY
                )
            ),
            new ArrayList<>(
                Arrays.asList(
                    Submarkets.SUBMARKET_OPEN,
                    Submarkets.SUBMARKET_STORAGE,
                    Submarkets.SUBMARKET_BLACK,
                    Submarkets.GENERIC_MILITARY
                    )
            ),
            new ArrayList<>(
                Arrays.asList(
                    Industries.HEAVYBATTERIES,
                    Industries.HEAVYINDUSTRY,
                    Industries.REFINING,
                    Industries.MINING,
                    Industries.MILITARYBASE,
                    Industries.TAG_MILITARY,
                    Industries.WAYSTATION,
                    Industries.MEGAPORT,
                    Industries.POPULATION
                )
            ),

            0.3f,
            true,
            true);
       
        JumpPointAPI InnerJP = Global.getFactory().createJumpPoint("applew_inner_jumppoint", "Applew Inner Jump Point");
        InnerJP.setCircularOrbit(Applew, 180f, 1900, 49);
        system.addEntity(InnerJP);
    }
}
[close]

I'm appreciate any reply.
« Last Edit: September 01, 2022, 08:26:14 AM by cess183 »
Logged

superjosh250

  • Lieutenant
  • **
  • Posts: 85
    • View Profile
Re: [HELP] Having trouble creating a star system
« Reply #1 on: August 29, 2022, 02:21:53 PM »

Question, are you a coder? I don't mind helping but if you're building off your own code, I can't really assist.
Logged

Great Wound

  • Captain
  • ****
  • Posts: 308
    • View Profile
Re: [HELP] Having trouble creating a star system
« Reply #2 on: August 29, 2022, 02:34:39 PM »

Another question:

What tutorial are you following?

When I did mine I copied vanilla and made adjustments, only referencing tutorials for specific parts. You look like you're trying to do it someone else's way.

cess183

  • Ensign
  • *
  • Posts: 6
    • View Profile
Re: [HELP] Having trouble creating a star system
« Reply #3 on: August 29, 2022, 02:36:07 PM »

Question, are you a coder? I don't mind helping but if you're building off your own code, I can't really assist.

Do you mean not using any guideline? I do try to follow the tutorial on fandom.https://starsector.fandom.com/wiki/Intro_to_Modding
No I don't think I'm building my own code.
Logged

superjosh250

  • Lieutenant
  • **
  • Posts: 85
    • View Profile
Re: [HELP] Having trouble creating a star system
« Reply #4 on: August 30, 2022, 10:51:17 AM »

Yeah, Great Wound is right. You should be using Vanilla Star systems to build your own. I don't code but looks like you're missing all sorts of instructions. You're calling for Nexerlin in your modplugin. Ensure you have the nexerlin mod enabled for that, or completely remove Nexerlin from the modplugin. Your market code lines should really be part of your system file, that way you can find errors if there are any.

Looks like your jumping through hoops for the game to do a simple Starsystem creation.

Logged

cess183

  • Ensign
  • *
  • Posts: 6
    • View Profile
Re: [HELP] Having trouble creating a star system
« Reply #5 on: August 30, 2022, 02:04:13 PM »

Yeah, Great Wound is right. You should be using Vanilla Star systems to build your own. I don't code but looks like you're missing all sorts of instructions. You're calling for Nexerlin in your modplugin. Ensure you have the nexerlin mod enabled for that, or completely remove Nexerlin from the modplugin. Your market code lines should really be part of your system file, that way you can find errors if there are any.

Looks like your jumping through hoops for the game to do a simple Starsystem creation.


The part with nexerlin is just for checking if the radom core system is enabled or not. Theoretically it is safe. I do tried to start the game without the nexerlin in my modplugin but the log just shows me the same error.

[edite: Oops I forgot to export the new code into jar, now it shows aother error.
       here is the log:
Spoiler
40044 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Industry [important] not found
java.lang.RuntimeException: Industry [important] not found
   at com.fs.starfarer.campaign.econ.Market.addIndustry(Unknown Source)
   at com.fs.starfarer.campaign.econ.Market.addIndustry(Unknown Source)
   at data.scripts.world.CEGen.addMarketplace(CEGen.java:49)
   at data.scripts.world.systems.SystemAlpha.generate(SystemAlpha.java:43)
   at data.scripts.world.CEGen.generate(CEGen.java:82)
   at data.scripts.CEModPlugin.onNewGame(CEModPlugin.java:15)
   at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.dialogDismissed(Unknown Source)
   at com.fs.starfarer.ui.N.dismiss(Unknown Source)
   at com.fs.starfarer.ui.newui.do.dismiss(Unknown Source)
   at com.fs.starfarer.ui.newui.o0Oo.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.Q.advance(Unknown Source)
   at com.fs.starfarer.ui.v.advanceImpl(Unknown Source)
   at com.fs.starfarer.ui.Q.advance(Unknown Source)
   at com.fs.starfarer.title.TitleScreenState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
[close]
]

About the market code. If you mean those involved the market API in the gen file that's just a method. I saw it in many other mods and in the tutorial I used. Planets' market codes are in the star system file. And the Visual Studio Code(the IDE) has no problem with the code.

Thanks for the suggestion though, have a nice day.
« Last Edit: August 30, 2022, 02:22:03 PM by cess183 »
Logged

cess183

  • Ensign
  • *
  • Posts: 6
    • View Profile
Re: [HELP] Having trouble creating a star system
« Reply #6 on: September 01, 2022, 08:23:30 AM »

btw does anyone know how to test code without export it into jars?
Logged

cess183

  • Ensign
  • *
  • Posts: 6
    • View Profile
Re: [HELP] Having trouble creating a star system{has been solved}
« Reply #7 on: September 01, 2022, 08:28:38 AM »

After I change the tags that I added in market's industry part the code runs perfectly fine.
Logged

Great Wound

  • Captain
  • ****
  • Posts: 308
    • View Profile
Re: [HELP] Having trouble creating a star system
« Reply #8 on: September 01, 2022, 10:25:08 AM »

btw does anyone know how to test code without export it into jars?

Glad you got it sorted but might I suggest you take a look at my KoC (or more accuratly periphery planet pack which comes bundled with it). It contains 4 systems that were put together using nothing but a text editor, there's no need for IDEs or Jars. I suspect the tutorial is overcomplicating things. It seems like you've taken on a lot of needless hassle.

superjosh250

  • Lieutenant
  • **
  • Posts: 85
    • View Profile
Re: [HELP] Having trouble creating a star system{has been solved}
« Reply #9 on: September 01, 2022, 10:55:17 AM »

I agree with @GreatWound. I'd really only be messing with IDE's or Jars if I was an advanced coder, specifically to create new effects to patch into the base code. Making a StarSystem with industries is fairly simple without using a compiler.
Logged

cess183

  • Ensign
  • *
  • Posts: 6
    • View Profile
Re: [HELP] Having trouble creating a star system
« Reply #10 on: September 01, 2022, 06:01:34 PM »

btw does anyone know how to test code without export it into jars?

Glad you got it sorted but might I suggest you take a look at my KoC (or more accuratly periphery planet pack which comes bundled with it). It contains 4 systems that were put together using nothing but a text editor, there's no need for IDEs or Jars. I suspect the tutorial is overcomplicating things. It seems like you've taken on a lot of needless hassle.

Thank you for your suggestions. I'll surely check out your mod. It is great to see people like you supporting newcomers. Hope you all have a nice day. :)
Logged