Skip to content

Conversation

@Chryssie
Copy link

@Chryssie Chryssie commented Mar 1, 2025

This is a work in progress with some caveats:

  1. This is not backwards compatible, it should, however, be possible to make it backwards compatible by introducing a shim for the old require paths. I have managed to implement this in a manner that should be entirely backwards compatible in most cases. As in, mods that are not updated to the new format (see sn_better_target_monitor) should still work, provided they're not otherwise broken by 7.5. There may be exceptions if they depend on some very specific load order behaviours.
  2. I've only updated sn_mod_support_apis and sn_better_target_monitor to work with protected UI, however, they do work with it... mostly... These now work with protected UI.
  3. Working in protected UI appears to prevent you from using require on any user-defined scripts. This means that you cannot use that for dependency management. I primarily work in C# and am not familiar with lua so the only workaround i could find was to setup a global variable to replace the return statement with. I've attempted to use the same naming fashion as the scripts as to help avoid collisions, but it's probably less foolproof than the old system. I have replaced the globals with a very basic module system. The main purpose of it is to manage the initialisation functions as ui.xml loads scripts significantly earlier than the mission director would have. This includes being on the main menu. This allows dependent mods avoid rewriting their require statements as they can use the require function passed to them by the define function which will attempt to find the module from the module system and return that (after initialising it) instead of calling the native require which silently fails (returns nil) in protected UI mode.
  4. Update: All that I need to do for this to be technically ready is just to update the rest of the mods in the repo to support protected UI and probably implementing module overriding, since that previous system probably can already do that.

@Chryssie Chryssie force-pushed the master branch 12 times, most recently from d2e894a to 5ce956c Compare March 4, 2025 14:49
This is possible because 7.5 also fixed the `"_g = nil"` bug when loading scripts via `ui.xml`.
@Stroichik
Copy link

Thank you very much for all your efforts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants