Page 1 of 1

Deinit?

Posted: Sun Jan 28, 2024 7:32 am
by SupplyDepoo
Is there a way to run code when a mod is removed in order to clean up stuff that the player would not expect to stick around, such as surfaces added by the mod?

Re: Deinit?

Posted: Sun Jan 28, 2024 7:52 am
by ichVII
No. When the game opens a save file with a mod (lets call it modA), that the game doesnt run, the game has no access to modA. It should, however, be possible to have the init file of a different mod (modB), which is active, detect if modA is not active and if so, delete certain stuff, which modA created.

Re: Deinit?

Posted: Sun Jan 28, 2024 10:10 am
by Pi-C
If you've made some excessive changes that would persist even after your mod has been uninstalled, you could also define a command players can use to reset things. Naturally, the command should be called before the mod is uninstalled! (Example: In GCKI, players can "lock" their vehicles, which sets their 'active', 'operable', and 'minable' flags to false. After the mod has been removed, there'd be no way to drive, mine, or open the inventory of such vehicles, so I've added a command '/GCKI-reset' that makes all locked vehicles usable again.)

Re: Deinit?

Posted: Sun Jan 28, 2024 11:36 am
by SupplyDepoo
Great, thanks!