Resource:Power Grid Scrap Crash

Overview
The Fallout 4 settlement workshop power grid table will have incomplete, orphaned information if powered objects were improperly removed from the workshop which will eventually result in crashing while attempting to scrap objects or work with powered objects in workshop mode.


 * Powered objects are added to the power grid when you perform an action on them (build them, move them, attach wires between them) in Workshop mode. Papyrus scripts from mods cannot add objects to the power grid.
 * Objects are removed from the power grid when you scrap them, store them or otherwise disconnect them in Workshop mode. Once again, Papyrus scripts from mods cannot remove objects from the power grid.

The scrap crash is caused under 3 conditions:
 * 1) You removed a mod that had anything involved with power in it without first scrapping those items.
 * 2) You disabled/marked for delete an item involved with power.
 * 3) A mod scrapped an item involved with power that had been added to the grid.

Technical Details
Once an entry is orphaned, there is no longer any in-game way to remove them from the power grid in Workshop mode as there are no longer any links to them.

Orphaned entries in the power grid are ticking time bombs! They refer to objects that have already been deleted. Orphaned entries can only accumulate in a power grid. The more orphaned entries in a grid, the greater the chance that the game will happen to 'recycle' one of these defunct IDs as it generates new objects. Once an orphaned power grid entry is recycled to become a different form type, you will experience what is known as the Scrap Crash.

Terminology

 * "Reference" is an Object Reference that exists in a Cell.
 * "Power Reference" is a placed power connector, consumer, generator, terminal, etc.
 * "Spline Reference" is a placed "Bendable Spline" (BNDS) between the connectors of two different Power References.
 * "Workshop Reference" is the reference that hosts the "Power Grid" and all Power References must link to it with keyword WorkshopItemKeyword [KYWD:00054BA6].
 * "Base Form" is the activator, light, terminal, etc of the Reference.
 * "Spline Connection" is a field (only viewable in xEdit) on Power References and Spline References. All Spline Connections refer to a set of one Spline Reference and two Power References and represent a bi-directional connection between the Power References through the Spline Reference.
 * "Power Grid" is a field (only viewable in xEdit) on the Workshop Reference.
 * This contains all the "Power Connections" ([Power Grid\Connections]) for the Workshop and the "Nodes" are considered bi-directional through an optional "Line".
 * What Power Reference is what Node does not matter but that Node pair will only exist once in the entire Power Grid.
 * Wired connections will have the Line set to the Spline Reference for the connection.
 * If a connection is wireless or through a snap point, it will still have a Power Connection but it will have no Line (NULL - Null Reference [00000000]).

Requirements and Options
What an object is and how it works is based primarily on keywords, actor values.


 * Power Reference Requirements:
 * + Base Form can be any type allowed that supports Keywords and/or Actor Values
 * + Must be persistent
 * + Linked References:
 * To Workshop Reference with keyword WorkshopItemKeyword [KYWD:00054BA6]
 * + Wired Connection Requirements (for pre-wired Power References):
 * + CK:
 * A Spline Reference between the connectors of two different Power References
 * + xEdit:
 * One Spline Connection is required for each Spline Reference connecting to this Power Reference.


 * Spline Reference Requirements:
 * + Base Form can only be Bendable Spline (Default workshop wire: BlackWireSpline01 [BNDS:0001D971])
 * + Must be persistent
 * + Linked References:
 * To Workshop Reference with keyword WorkshopItemKeyword [KYWD:00054BA6]
 * + xEdit:
 * All Spline References should have one Spline Connection to each of the two Power References they connect.
 * It does not matter which Power Reference is which Spline Connection.


 * Base Form Requirements and Options:
 * + Any Form type allowed that supports Keywords and/or Actor Values
 * + Keywords (Field: KWDA - Keywords):
 * BlockPlayerActivation [KYWD:001CD02B] - For non switchable activators and or player interactable furniture
 * WorkshopCanBePowered [KYWD:0003037E] - For consumers, some connectors (eg, the large vanilla power pylon)
 * WorkshopPowerConnection [KYWD:00054BA4] - For wired connections
 * WorkshopStartPoweredOn [KYWD:0004455B] - For on/off switchable objects
 * WorkshopStartUnpoweredOff [KYWD:0004455C] - For on/off switchable objects
 * WorkshopSwitchActivatorKeyword [KYWD:001690A4] - For on/off switchable objects
 * + Actor Values (Field: PRPS - Properties):
 * PowerGenerated [AVIF:0000032E] - Any positive value, this makes these References power generators
 * PowerRadiation [AVIF:0000032F] - Any positive value, this controls the wireless transmission range for wireless consumers
 * PowerRequired [AVIF:00000330] - Any positive value, this is the amount of power required for consumers
 * WorkshopCanBePoweredAV [AVIF:0024A03A] - ?, only used by VaultTec DLC for vault pieces
 * WorkshopSnapTransmitsPower [AVIF:00000354] - 1.0, this controls whether the object makes power connections through snap points


 * Workshop Reference Requirements:
 * + Must be persistent
 * + Linked References:
 * All Power and Spline References should link to the Workshop Reference with keyword WorkshopItemKeyword [KYWD:00054BA6]
 * + xEdit:
 * A Power Grid

Resources

 * Fallout 4 CK Spline Tutorial
 * Power Grid Tools: F4SE Required Power grid repair tool. No options exist for console.
 * Workshop Framework 1.0.6 or higher has a safe method for scrapping powered objects via papyrus.