Skyrim Special Edition
0 of 0

File information

Last updated

Original upload

Created by

COACHWICKWACK

Uploaded by

Beefclot

Virus scan

Safe to use

Tags for this mod

About this mod

This script bundle includes two scripts: ElementDataExtractor and ReplaceElementsOnMatch. Both can export simple JSON with no duplicate keys.

Requirements
Permissions and credits
Changelogs
Donations
COACH's Awesome Sauce Scripting Power Pack (xEdit)
v1.0.0

I learned xEdit scripting for two weeks and wrote these scripts. I wrote these with xEdit 4.0.4, so presumably it should work for every version that uses the same IndexedPath formatting (untested on 4.1.5, but I suspect it won't work without refactoring). Both scripts allow for multiple queries for each selected record. The JSON written by both scripts won't be written until all selected records are processed. I'll probably write a couple more scripts to remove/add elements to a path. I'll probably also update these scripts for 4.1.5, whenever their documentation is fleshed out. Back and forward slashes in the element paths are interchangeable. Stringe replacement works for most elements, like integers and others untested.

ElementDataExtractor
This script will let you search a generic element path for an optional regex match and optional JSON export on match. You can also export a different, target element path and value for a record where searching the generic element path is matched or valid.

ElementDataReplacer
This script will let you search a generic element path for an optional regex match and replace either the generic element path value, or a target element path value with a replacement string. You can also export a JSON with your edited elements for selected records.

Installation:
Extract the scripts into your xEdit/Edit Scripts folder.

Why I did it:
I wanted to write a couple scripts like this while working on Somnium because one of our modded NPCs wasn't acting hostile to the player. We narrowed it down to a faction collision, where the player is assigned to two Factions: PlayerFaction and PlayerAlliesFaction. The modded NPC considered PlayerFaction as an Enemy, whereas it considered PlayerAlliesFaction as a Friend. The Friend relation overrides the enemy relation, so the modded NPC was friendly until we changed PlayerAlliesFaction to Neutral. We could've removed the player from the PlayerAlliesFaction, but we didn't want to break any weird mechanics in the game.

Problems/Solutions/Use cases

  • Problem: I have a modded NPC and my Player that are related to each other via Faction relations, and my modlist has hundreds of mods with hundreds of factions. I want to have my modded NPC be hostile to the player, but for some reason faction relations aren't working as intended.
  • Solution: Use ElementDataExtractor to write a JSON of every FACT record in the game, and use whatever language you want to process the JSON and find the collisions in faction relations between the modded NPC and the player. Alternatively, do a regex match on every faction with an XNAM entry for "PlayerFaction" and write to JSON for manual debug.

  • Problem: I updated a property name in a script that affects several objects/records, and I need to rename the property in xEdit. I don't want to write a custom script to do this one-time, hardcoded search and replace. I also want to replace the script name.
  • Solution: Use ElementDataReplacer to search the generic element path with a regex value match for that property. If I leave the target element path blank, my script will use the query path as the replacement path. I will use my replacement values (the property and script name) to rename my property and script name in my selected records.



First, I use ElementDataExtractor to check my element paths are valid:

Then, I fill out the fields for each replace operation happening on my selected records:

Finally, I get the result:

Big thanks to everyone for helping me learn xEdit scripting:
  • mator for writing mteFunctions. I used a lot of his functions to practice.
  • fire and zilav for answering epic technical questions
  • ElminsterAU for recommending JsonDataObjects
  • m8r98a4f2
  • jonathanostrus