Deinit?

Place to get help with not working mods / modding interface.
User avatar
SupplyDepoo
Filter Inserter
Filter Inserter
Posts: 305
Joined: Sat Oct 29, 2016 8:42 pm
Contact:

Deinit?

Post 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?
ichVII
Fast Inserter
Fast Inserter
Posts: 103
Joined: Mon Feb 27, 2017 10:16 pm
Contact:

Re: Deinit?

Post 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.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1726
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Deinit?

Post 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.)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
User avatar
SupplyDepoo
Filter Inserter
Filter Inserter
Posts: 305
Joined: Sat Oct 29, 2016 8:42 pm
Contact:

Re: Deinit?

Post by SupplyDepoo »

Great, thanks!
Post Reply

Return to “Modding help”