[Starsector Mods][0.95.1a] LunaLib 1.1.2

  • Post category:Mods
  • Post comments:0 Comments

LunaLib
A Library mod for Mod Developers. There is no point in downloading this unless a mod requires you to do so.
It adds a variety of utility functions and adds a few features that Mod Devs can make use of.

Download V1.1.2
Older Versions and Changelog
(Last Updated: 15.12.22)

For Users:

LunaSettings
An Ingame UI Solution for Mod Configurations.

  • Can be Opened in the campaign with F2 (Configurable) or during the new game creation screen.
  • Settings persist between mod updates.

Spoiler: click to expand
Save Location
All Global Settings are saved in:
starsector/saves/common/modname.json.data
The File will be re-created automaticly with default settings if removed.

Save-Specific Settings are saved within the Savefile, and cant usually be changed.

Debug Screen
A screen that includes tools for searching for entities in the Sector, and tools for cheating in ships and items.
To access it, you need to set a Keybind in the Mod Settings menu.

For Modders:

LunaLibs’ Github.
Documentation.

LunaLib Adds:

  • LunaSettings (An expandable UI Config Solution
  • LunaInteractionDialog (A wrapper around InteractionDialogPlugin, offering preset variables and some utility methods.
  • LunaUtils (A decent amount of utility classes.)
  • LunaMemory (A class for easier MemoryAPI management)
  • LunaTimer (A simple class for campaign timers.)
  • LunaExtensions (Kotlin-Extension Functions that add some much needed functionality to some of Starsectors APIs)
  • LunaCMDs (A tiny selection of Rules.CSV scripts)

If you encounter any issues, have any questions or require some help, feel free to message me on Discord @Lukas04#0856

Credits:

SpeedRacer, President Matt Damon: Provided me with help for the Custom UI Screens.
Wisp: Gave lots of feedback, Provided a good selection of Extension Functions. LunaMemory is inspired by his Memory Delegates.

Why yet another Lib?:
Mostly because i wanted to add a few things to a library to extend Modding functionality, but MagicLib is currently not actively maintained.


Oh hell yeah! I can’t wait to see how mods will end up using it.

More UI based stuff is definitely nice.


Lovely, will make use of this. Thanks for your hard work. I was working on my own solution to config some settings that I needed for playtesting, but this seems to have that sorted :)

UI Config? Hells yes!

Released a small update, which fixes LunaSettings input locations to be in the wrong position on some resolutions

Also moved all Kotlin-Extensions from lunaUtil.LunaExtensions.kt to lunalib.LunaExtensions.*
This is to make sure that they scale better as more are added, as keeping all Extensions in one file would become heavily bloated.


Great work!  I’ll start on getting this integrated with DCR.

Oh this is really interesting!

I could see someone making an addon that essentially wraps Nexelerin’s various config file setting with this, as there are a large number of “scenarios” that people have come up with that rely on changing a bunch of values in the config file.

Question: could a mod maker use the enum field to have preset combinations of the different fields which are then populated? Like say the user selects “standard start” from an enum, and then that changes the user enterable field “starting ship” to “Wolf”, but then the player could manually change it to something else?

I feel like I explained myself badly there, but the idea is to have preset options which can then be tweaked by the user.

[Edit] It also just ocured to me that this library makes it trivially easy to do something like game difficulty settings that can be customized either at game start or mid playthrough. Thats kind of excellent!


I could see someone making an addon that essentially wraps Nexelerin’s various config file setting with this, as there are a large number of “scenarios” that people have come up with that rely on changing a bunch of values in the config file.

It also just ocured to me that this library makes it trivially easy to do something like game difficulty settings that can be customized either at game start or mid playthrough. Thats kind of excellent!

Yeah both of those would be easy to implement, though, changing Nexelerin behaviour itself would not really work in that sense, except if Nexelerin itself would integrate with the mod, which id doubt since it has its own Settings Menus for its sector specific content. (Which also partly inspired me to make this). The mod itself uses its own saving system in saves/common, as thats the only place modders get Write FileIO access to, which means it can not be used to overwrite configs in mod folders. There is also no integration with MagicSettings, due to the same reason, and because having weird cross-compatibility would open lots of cases for weird behaviour.

Question: could a mod maker use the enum field to have preset combinations of the different fields which are then populated? Like say the user selects “standard start” from an enum, and then that changes the user enterable field “starting ship” to “Wolf”, but then the player could manually change it to something else?

All fields are loaded on application load, so having another one appear only after one option was selected wouldnt currently work. It would also be very janky to update how a Field functions after its already added to the list of Options. What i would do in this case, is probably to keep that Enum, and add a String field below that would only do something if the Enum above has something selected.
I.e The enum could be a list of Starter ships, but one of them says “Custom Start”, which you would then read a ship ID from another String Field.


Great work!  I’ll start on getting this integrated with DCR.

Seconded. Time to ditch those settings files and update Stelnet and Starpocalypse to use in-game configuration… probably in Jan when I have time :D


Starsector really needed something like LunaSettings, thank you for making it! Judging by that GIF and the documentation, it looks like you’ve done a great job, too. I’m hoping to integrate it into all of my mods before too long!

Released a mid-sized update
Part of the update allows modders to now add Keybinds in the Settings menu.
Also adds a Debugging Screen, that can be set through LunaLibs own Settings Window.

The Debug Screen mostly bases on one of my other mods, DevUtils, but ive merged a rework of it in to this Lib, as this way maintaining both mods is easier.


This is excellent! I was just looking for something like Skyrim’s Mod Config Menu or the incredible and cooperative mod ecosystem in Hollow Knight, and was really surprised that nothing like that seemed to exist for Starsector. Totally going to use this.

I got around to checking out LunaSettings integration yesterday and have some questions/feedback.

  • It was extremely easy to set up, so thank you for that! I also really appreciate the formatting options and the ability to add read-only text blocks.
  • The gui is very clean and responsive, but I think the boolean and enum elements don’t hold up to the quality of everything else. If possible, I think it would be an improvement for the bool button to display either true or false instead of “true/false,” depending on its state. The enum element could be improved by preventing other options from being highlighted and showing their tooltips while the orange selection list is shown. Also, I think it would be intuitive for the list to disappear when the user clicks elsewhere.
  • If a mod only has new game options it will still show up in the side panel after the start of a game, even though options are no longer available for it. It might be better not to list mods in such cases, but I think there’s an argument for keeping it as is, so *shrug*
  • Are newGame settings intended only for options that, for technical reasons, can’t be changed after a game starts? I imaging many users would like to choose for themselves whether individual settings apply globally or only to a specific save, regardless of whether or not the setting supports changes mid-game.

Generally, I’m very impressed with this library. It already has all of the features I’ll need to solve a lot of the problems with my clunky config files. I’ve been contemplating making something like this for several years while hoping someone else would, so again, thanks!  ;D


I got around to checking out LunaSettings integration yesterday and have some questions/feedback.

  • It was extremely easy to set up, so thank you for that! I also really appreciate the formatting options and the ability to add read-only text blocks.
  • The gui is very clean and responsive, but I think the boolean and enum elements don’t hold up to the quality of everything else. If possible, I think it would be an improvement for the bool button to display either true or false instead of “true/false,” depending on its state. The enum element could be improved by preventing other options from being highlighted and showing their tooltips while the orange selection list is shown. Also, I think it would be intuitive for the list to disappear when the user clicks elsewhere.
  • If a mod only has new game options it will still show up in the side panel after the start of a game, even though options are no longer available for it. It might be better not to list mods in such cases, but I think there’s an argument for keeping it as is, so *shrug*
  • Are newGame settings intended only for options that, for technical reasons, can’t be changed after a game starts? I imaging many users would like to choose for themselves whether individual settings apply globally or only to a specific save, regardless of whether or not the setting supports changes mid-game.

Generally, I’m very impressed with this library. It already has all of the features I’ll need to solve a lot of the problems with my clunky config files. I’ve been contemplating making something like this for several years while hoping someone else would, so again, thanks!  ;D

2. An annoying thing with Buttons in Starsectors implementation is that their text cant be changed after creation, at best i could try making the buttons text empty, and overlaying a paragraph over it, not sure how well that would work though. I definitly need to improve the enums though, and good suggestion on making them dissapear when clicked somewhere else, though im not sure if i can implement that, since i cant be sure if a click on the button would be processed before it processes the click for exciting. I can make a rightclick close it atleast though.

4. Ive been considering removing the newgame option, i did intend it to be a setting that will always reset to a default, and the modders can make sure that a save will always have the same setting as that from first creation on, but i do realize now that its something that a modder should probably just do themself. I also did realize that having to set generation configs for each run would get tiring, so i will most likely remove this. I will put a deprecation warning on the doc for it. 


Sounds good. I figured a lot of that was due to API limitations, but figured I might as well mention it anyway.

Removing the newGame option would certainly simplify things and clean them up a bit, but I do think it’s useful. There will inevitably be cases where a setting can’t be changed after new game creation, and it would be a bit messy to display those options once changing them no longer has an effect. There are a slew of other considerations though, so I can respect deprecating it.

Feel free to PM me on discord, if you like. I’m often very slow to respond though.

Leave a Reply