Hey, I'm new to modding this game. I've got ship and weapon modding down no problem, but now that I'm trying to make a faction to use the stuff I've made, I hit a wall. Got the faction to show up in game, got the star system generated, now I just need to add a market to one of the planets. I cannot for the life of me figure out how to do this. The closest that I've gotten is for the planet to register as "under the control" of my faction, but when I go to it, it only has one dialogue option and when you mouse over the conditions at the top right, it puts the "hovered over" click on repeat. Here is the code for my market:
Spoiler
PlanetAPI ventor_ii = system.addPlanet("ventor_ii", ventor_star, "Ventor II", "terran-eccentric", 180, 145, radiusAfter1+2600, 210);
SectorEntityToken ventor_station = system.addCustomEntity(
"ventor_station",
"Ventor II Station",
"station_side04",
"ventoran");
ventor_station.setCircularOrbitPointingDown(system.getEntityById("ventor_ii"), 275, 600, 45);
SectorEntityToken system1 = system.getEntityById("ventor_ii");
MarketAPI ventor_ii_market = Global.getFactory().createMarket("ventor_market", ventor_ii.getName(), 8);
ventor_ii_market.setPlanetConditionMarketOnly(false);
ventor_ii_market.addCondition(Conditions.HABITABLE);
ventor_ii_market.addCondition(Conditions.MILD_CLIMATE);
ventor_ii_market.addCondition(Conditions.ORE_RICH);
ventor_ii_market.addCondition(Conditions.RARE_ORE_RICH);
ventor_ii_market.addCondition(Conditions.ORGANICS_PLENTIFUL);
ventor_ii_market.addCondition(Conditions.FARMLAND_ADEQUATE);
ventor_ii_market.addCondition(Conditions.POPULATION_8);
ventor_ii_market.getFirstCondition(Conditions.HABITABLE).setSurveyed(true);
ventor_ii_market.setPrimaryEntity(ventor_ii);
ventor_ii.setMarket(ventor_ii_market);
ventor_ii_market.setFactionId("ventoran");
ventor_ii_market.addIndustry(Industries.POPULATION);
ventor_ii_market.addIndustry(Industries.STARFORTRESS);
ventor_ii_market.addIndustry(Industries.FARMING);
ventor_ii_market.addIndustry(Industries.MEGAPORT);
ventor_ii_market.addIndustry(Industries.HEAVYBATTERIES);
ventor_ii_market.addIndustry(Industries.HIGHCOMMAND);
ventor_ii_market.addIndustry(Industries.MINING);
ventor_ii_market.addIndustry(Industries.ORBITALWORKS);
ventor_ii_market.addIndustry(Industries.REFINING);
ventor_ii_market.addIndustry(Industries.FUELPROD);
PlanetAPI ventor_iia = system.addPlanet("ventor_iia", ventor_ii, "Ventor IIa", "barren", 180, 65, 450, 40);
That is in my Mod Plugin .java.
Result:
I think you're actually just missing a few small things, like setting the market conditions to 'surveyed' and maybe adding the submarkets. BUT, for the sake of futureproofing and making it easier for you to do this again later when you want to add more markets, maybe try adding an addMarketplace() function to one of your scripts and calling that instead!
Here's mine, you can copy it entirely if you want:
public static MarketAPI addMarketplace(String factionID, SectorEntityToken primaryEntity, ArrayList<SectorEntityToken> connectedEntities, String name,
int size, ArrayList<String> marketConditions, ArrayList<String> submarkets, Boolean WithJunkAndChatter, Boolean PirateMode) {
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", newMarket.getFaction().getTariffFraction());
if (submarkets != null) {
for (String market : submarkets) {
newMarket.addSubmarket(market);
}
}
for (String condition : marketConditions) {
try {
newMarket.addCondition(condition);
} catch (RuntimeException e) {
newMarket.addIndustry(condition);
}
}
if (connectedEntities != null) {
for (SectorEntityToken entity : connectedEntities) {
newMarket.getConnectedEntities().add(entity);
}
}
globalEconomy.addMarket(newMarket, WithJunkAndChatter);
primaryEntity.setMarket(newMarket);
primaryEntity.setFaction(factionID);
if (connectedEntities != null) {
for (SectorEntityToken entity : connectedEntities) {
entity.setMarket(newMarket);
entity.setFaction(factionID);
}
}
if (PirateMode) {
newMarket.setEconGroup(newMarket.getId());
newMarket.setHidden(true);
primaryEntity.setSensorProfile(1f);
primaryEntity.setDiscoverable(true);
primaryEntity.getDetectedRangeMod().modifyFlat("gen", 5000f);
newMarket.getMemoryWithoutUpdate().set(DecivTracker.NO_DECIV_KEY, true);
} else {
for (MarketConditionAPI mc : newMarket.getConditions()) {
mc.setSurveyed(true);
}
newMarket.setSurveyLevel(SurveyLevel.FULL);
}
newMarket.reapplyIndustries();
return newMarket;
}
and then in your systemgen script you would call it like so:
// the Kadur are reduced to hiding in their heavily-guarded star fortress, towed here through hyperspace following the final battle over Oasis
SectorEntityToken khs_refugestation = system.addCustomEntity("khs_refugestation", "Star Fortress Requiem", "station_side06", "kadur_remnant");
khs_refugestation.setInteractionImage("illustrations", "industrial_megafacility");
khs_refugestation.setCustomDescriptionId("khs_requiem");
khs_refugestation.setCircularOrbitPointingDown(gehennaII, 0, 220, 70);
MarketAPI khs_refugestationmarket = addMarketplace(
"kadur_remnant", // faction id
khs_refugestation, // id or reference of the PRIMARY ENTITY (i.e. in this case the station, could be that or the planet for you)
null, // LIST of secondary entities, if you want a typical station-and-planet market you'd put a single-item list with one of them in it here
"Star Fortress Requiem", // name of the market
5, // size of the market
new ArrayList<>(
Arrays.asList( // list of market_condition and/or industry ids
"population_5",
"frontier",
"headquarters",
"stealth_minefields",
"khs_kadur_refugees",
"khs_kadur_majority",
"khs_hardened_populace",
"dark",
"hydroponics_complex",
Industries.POPULATION,
Industries.SPACEPORT,
Industries.HEAVYBATTERIES,
Industries.MILITARYBASE,
Industries.WAYSTATION,
Industries.STARFORTRESS_MID)),
new ArrayList<>(
Arrays.asList( // which submarkets to generate
Submarkets.GENERIC_MILITARY,
Submarkets.SUBMARKET_BLACK,
Submarkets.SUBMARKET_OPEN,
Submarkets.SUBMARKET_STORAGE)),
true, // with junk and chatter?
false); // pirate mode? (i.e. hidden)
// can't figure out how to add items inside my addmarketplace, too complicated, just brute force it separately
khs_refugestationmarket.addIndustry(Industries.ORBITALWORKS,new ArrayList<>(Arrays.asList(Items.PRISTINE_NANOFORGE)));