A setting does not always need a window#

A toggle, number or mode selector can use a shared extension settings interface. A special panel can use a custom window. One third-party option is X4 Mod Support APIs, sn_mod_support_apis: Simple Menu API supports settings/menu construction, and Lua Loader API assists loading and delayed initialization.

Distinguish the library from the game#

Register_OnLoad_Init and MD Simple_Menu_Options belong to that library; they are not guaranteed in clean X4. Read the installed version's documentation, declare content.xml and ui.xml dependencies, and wait for readiness.

A setting's route#

Define a unique ID, text, type and default; register a change handler; validate and store the value in the appropriate context. Defaults must not overwrite saved choices on every load. Menu rebuilding must not repeat an expensive operation.

Verification#

Test first opening, changing the value, reopening, saving and loading. Check missing or incompatible dependencies separately. Use current library documentation rather than an unverified example for an older release.