Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Best Practices and Common Pitfalls  (Read 3264 times)

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Best Practices and Common Pitfalls
« on: April 08, 2019, 06:10:07 PM »

I couldn't find any threads about these things, so I thought I'd start one.

So what are the best practices for creating Starsector mods that:
  • Avoid conflicts with other mods
  • Can be added to pre-existing games
  • Can be removed from games without leaving behind a bunch of bloat
  • Are easy to maintain
  • Work well in other ways that I haven't considered

Edit: I just found DR's Modding Guidelines, which seem very informative! I'm sure many of you have already seen it, but it's new to me.
« Last Edit: April 08, 2019, 10:03:15 PM by Sundog »
Logged

Midnight Kitsune

  • Admiral
  • *****
  • Posts: 2847
  • Your Friendly Forum Friend
    • View Profile
Re: Best Practices and Common Pitfalls
« Reply #1 on: April 08, 2019, 08:24:48 PM »

-DON'T make extra work for other modders!
-DO use a WHITElist!
-DON'T use anything from other mods (hull mods, weapons, ships, etc) in ship variants!
-ASK before porting or modding someone else's mod!
--DON'T post said modded mod without the original author's permission!
Logged
Help out MesoTroniK, a modder in need

2021 is 2020 won
2022 is 2020 too

Gwyvern

  • Captain
  • ****
  • Posts: 318
  • I build ships.
    • View Profile
Re: Best Practices and Common Pitfalls
« Reply #2 on: April 08, 2019, 08:37:49 PM »

  • Can be added to pre-existing games
  • Can be removed from games without leaving behind a bunch of bloat

These two in particular are going to heavily limit your scope to be honest.
« Last Edit: April 08, 2019, 08:41:47 PM by Gwyvern »
Logged

Snrasha

  • Admiral
  • *****
  • Posts: 705
    • View Profile
Re: Best Practices and Common Pitfalls
« Reply #3 on: April 08, 2019, 09:15:20 PM »

You can look on the mod list, for the two:
   Can be added to pre-existing games
    Can be removed from games without leaving behind a bunch of bloat

This is the difference with Misc and Utility mod, they can be added on a pre-existing game but only utility mod can be removed.

For be removable, you need to have 0 ship, 0 weapon, 0 fighter, 0 hullmod, 0 shipsystem, 0 entity on the world  added(but also 0 script saved), if you want know.
" Upgraded Rotary Weapons" modify just sometime who exist on the vanilla and do not cause issue if you remove it.

Example on some Misc:
    [0.9a] Active Gates by toast               Add entity on the world, logic than you cannot remove      
    [0.9a] Automatic Orders by Blothorn       Add hullmod/orders
    [0.9a] Gladiator Society by Snrasha        Add ships
    [0.9a] Unknown Skies by Tartiflette           Add entity on the world

Tecnically, a thing than you can remove without problem, this is something than the game do not save on the save.


For it:
    Avoid conflicts with other mods
Just do not modify vanilla and talk with others peoples on the Discord for be sure.
For it: Well, really depends of what you want to do. (Gladiator can be hard to maintain, SAD mod is insanely the most hard because a fanmod and a faction mod can be pretty easily when the mod is finish(Artefact))
 Are easy to maintain
For it: Dialog your ideas with the Discord people:
 Work well in other ways that I haven't considered
« Last Edit: April 08, 2019, 09:19:22 PM by Snrasha »
Logged
I am pretty bad on english. So, sorry in advance.

Gladiator Society
Add battle options on Com Relay/ Framework for modders for add their own bounty.

Sanguinary Autonomist Defectors A fan-mod of Shadowyard.

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Best Practices and Common Pitfalls
« Reply #4 on: April 08, 2019, 09:30:32 PM »

-DON'T make extra work for other modders!
-DO use a WHITElist!
-DON'T use anything from other mods (hull mods, weapons, ships, etc) in ship variants!
Good tips! Yeah, MesoTronic already lectured me about that. Pretty rude to use other people's content in ways they don't intend.

  • Can be added to pre-existing games
  • Can be removed from games without leaving behind a bunch of bloat

These two in particular are going to heavily limit your scope to be honest.
Yeah, I've already run into a few situations that made it tough to pull these off in the small mods I'm working on, but I think I've managed to work around them in a reasonable way. The biggest problem I had was that references to transient scripts were remaining in save files, preventing them from loading without the script being defined. The solution I eventually settled on looks like this:
Code
package sun.nb;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import sun.nb.campaign.CampaignPlugin;

public class ModPlugin extends BaseModPlugin {
    CampaignScript script;

    @Override
    public void beforeGameSave() {
        Global.getSector().removeTransientScript(script);
        Global.getSector().removeListener(script);
    }

    @Override
    public void afterGameSave() {
        Global.getSector().addTransientScript(script = new CampaignScript());
    }

    @Override
    public void onGameLoad(boolean newGame) {
        Global.getSector().registerPlugin(new CampaignPlugin());
        Global.getSector().addTransientScript(script = new CampaignScript());
    }
}
It seems to work, but I'd appreciate feedback about any shortcomings this method may have.

@Snrasha:
Thanks for all those examples! I guess it makes sense that any mod that adds it's content to a save file couldn't be removed. Is there any convention for a mod 'uninstall' procedure for a mod to remove it's own content?

Just do not modify vanilla
To what extent does this apply? For some mods the whole point is to modify vanilla.
« Last Edit: April 08, 2019, 09:34:42 PM by Sundog »
Logged

Snrasha

  • Admiral
  • *****
  • Posts: 705
    • View Profile
Re: Best Practices and Common Pitfalls
« Reply #5 on: April 11, 2019, 08:41:22 AM »


Just do not modify vanilla
To what extent does this apply? For some mods the whole point is to modify vanilla.

Oups, wrong for that, you can modify vanilla like a balance mod who can be probably retired after without problem.
Just than Balance mod is a pitfall for many peoples, like every faction mods are balanced around vanilla. (After, this is a pitfall, sometime, we can get probably good balance mod. Because yeah, if you compare the balance of the vanilla, just look the last tournament on the discord for see every issues xD)

But else yeah, technically, "add a mod" is per definition "modify the vanilla" xD, so very stupid of my part.
Logged
I am pretty bad on english. So, sorry in advance.

Gladiator Society
Add battle options on Com Relay/ Framework for modders for add their own bounty.

Sanguinary Autonomist Defectors A fan-mod of Shadowyard.

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Best Practices and Common Pitfalls
« Reply #6 on: April 11, 2019, 01:04:47 PM »

Not stupid at all! In fact, in many ways I agree with you. A pet peeve of mine is when a mod (for any game) changes something about vanilla that has nothing to do with the mod, and isn't in it's description. Thankfully I can't think of any SS mods that do that, but it happens.

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
Re: Best Practices and Common Pitfalls
« Reply #7 on: April 15, 2019, 11:30:21 AM »

Some to add :D

- DO clearly state the gameplay changes made by your mod in its forum thread OP
- DO make variables player-editable in a settings file or ingame dialog, where appropriate
- DO allow portions of your mod to be toggled on or off in a settings file or ingame dialog, where possible
- DO incorporate and interact with content from other mods, where appropriate and with the permission of those mods' authors
Logged
Kadur Remnant: http://fractalsoftworks.com/forum/index.php?topic=6649
Vayra's Sector: http://fractalsoftworks.com/forum/index.php?topic=16058
Vayra's Ship Pack: http://fractalsoftworks.com/forum/index.php?topic=16059

im gonna push jangala into the sun i swear to god im gonna do it