Injecting or Overriding Production Settler Creation - kinggath/WorkshopFramework GitHub Wiki
Injecting or Overriding Production/Settler Creation
Ultimately, these will be added to the API as well, but until the community has the time to kick the tires a bit, I don't want to rush to provide script injection to everyone, as we all know - injections can cause issues and even crashing if the player fails to uninstall a mod correctly.
This portion of the Framework aims to alleviate that for workshop specific injection and overrides (though as long as this methodology withstands field-testing in the workshop department, there's no reason it can't be applied to other parts of the game as well).
In order to facilitate auto-cleaning LeveledLists, I extrapolated them out to FormLists that will fill the LeveledLists on start-up. This way, the default leveled lists can be rebuilt each time at startup and avoid the crashes and other issues normally associated with injected mods that weren't uninstalled correctly. Since the framework handles the rebuilding, it can easily track all of the changes, and the mods involved so that uninstalling one mod doesn't break the injection of every other.
Which means: No need for uninstallers and no risk of uninstalling breaking every other mod that uses this injection system.
You'll find a quest in the Workshop Framework called WSFW_InjectionManager. This has two key functions you'll want to know about:
AddToList RemoveDefault
These allow you to add new things to the lists, and remove existing things if you want to change them out completely. The default leveled lists you'll be injecting to are set to calculate for all levels and for each item in count.
AddToList(Form aTargetList, Form aAddForm)
- aTargetList - This should be any of the LeveledActor or LeveledItem properties on the quest. Note for the WorkshopVendorInventory series, there are 3 of them in an array, one for each level of the shop.
- aAddForm - This should be the additional LeveledActor or LeveledItem option you want to inject into the corresponding form.
RemoveDefault(Form aFormToRemove, Form aTargetList)
- aTargetList - This should be any of the LeveledActor or LeveledItem properties on the quest. Note for the WorkshopVendorInventory series, there are 3 of them in an array, one for each level of the shop.
- aFormToRemove - This should be the item you'd like to remove. To see what each list has in it by default, search FormLists for the prefix "WSFW_InjectionDefaults_"