Tes3Mod:Creating Clean Mods

WARNING: Much of the advice listed here is out of date. "Hex editing a mod?" Yikes! TESTool will do a lot of cleaning and is pretty good, though it may be overenthusiastic at times. If you want to get down and dirty, use Enchanted Editor. TESAME is also a good alternative.

----
I'm more than just a little surprised at how easy it is to create a dirty mod. Little things like accidentally changing 
information on a global object (a light, a static, a container) while you're first getting the hang of things, can 
literally double the size of your mod, and impact the entire "world" of Morrowind. Not to mention, potentially, other
peoples' mods... or the savegames of people to which you distribute your mod. 

I'd like to make a few suggestions to ANYONE developing a mod. Before EVER releasing, you should scrutinize the 
following: 
# Save your ESP
# Goto File, Data Files, select your ESP, and hit Details
# You should see a list of everything your ESP changes when employed

Learn to read and understand this list. Every single line of it. If you find it's tremendously long, when you've 
only added one internal cell with a few pieces of furniture, then your mod is not clean. You have three choices 
at that point: 
# Start Over
# Hex-edit your ESP to remove the improper entries (this isn't as hard as it sounds, actually)
# Release a dirty mod. 

Starting from the top of the details, you'll have a list of all the new objects you've added or modified from the original 
with your ESP. An example list: 
    SCPT ds_saree_scpt_bottle 
    SCPT ds_saree_scpt_winerack 
    ACTI _ds_saree_vsva_winerack 
    MISC _ds_saree_vsva_skey 
    STAT _ds_saree_vsva_crate 
    CONT barrel_01 
    CELL 

The list ends with the first reference to a CELL. The column on the left lists the type of object. I have listed 
here two scripts, an activator, a miscellaneous, a static, and a container. Their names are listed to the right. 
Remember, these are objects I have added or changed from the original.  The list contains:
    A script, which is assigned to a special bottle. 
    A script, which is assigned to a winerack. 
    An activator, a winerack in Saree's shop. 
    A misc, Saree's key. 
    A static, a crate in Saree's shop. 
    A container, barrel_01. 

I know I keep saying this, but keep in mind this list should only reflect entirely new objects you have added, 
or objects you have changed from the original. Keeping this in mind, and keeping in mind the question "am I clean?"
I now scrutinize this list. I ask, for each object, "New object: am I actually using this? Changed object: did I 
really, truly, positively mean to change this from the original?" 

The scripts are new, and I am certainly using them. Ditto for the activator and key. The crate seems a little funny, 
so I jump off of the list, and hit Cancel on the Data Files dialogue (so as to prevent having to re-load the entire 
ESP). I open up the VSVA interior cell (selecting it from the list of cells) and hunt down that object from the list
at the lower-right (made much easier since I have a distinguished name for it). Oh, yes, I see now - I had to make a
distinguished "crate" object that a script operates upon. Scripts like objects whose "references persist", and the 
original static crate (furn_crate_open_01) does not persist. Of course, I could have just dropped in furn_crate_open_01,
set it to persist, and hit that Save button on the object - but then I wouldn't have a clean ESP, since I'd have just 
modified 84 other crates in the original ESM! You scripters in the audience should also immediately recognize the fact
that operating on an object almost always requires you have a unique name for that object. Otherwise, if you just specify
"furn_crate_open_01", you may end up operating on some crate halfway across Vvardenfell! If you need a script to operate
on an object, you'll find you nearly always need to create your own special object for it - DO NOT simply change the 
name and properties of some existing object to suit your needs! That would be dirty!

One more object. The container, barrel_01. Ah, yes, I stuck a barrel downstairs with five gold in it. 
That's fine, right? Wrong. This is exactly the kind of mistake the novice is bound to make, and it's the
kind of thing the paranoid mod-downloader has every right to fear. When you stick objects into a container,
you're not harmlessly creating just one container with the objects you want, you're changing the contents 
for each and every instance of that object in the entire world. barrel_01 was originally empty, looked like 
a prime target to me. Now, I'll find that if I check the contents of any instance of barrel_01, anywhere in 
the world, I'll find they all have five gold in them! 

It gets worse. I may realize the error of my ways, change barrel_01 back to the way it was, and as a wiser mod
builder, make my own copy of barrel_01 (_ds_saree_vsva_barrel01), and change its contents to my heart's content. 
But my mod is still dirty. When I go back to my list of objects, I'll now find: 
    SCPT ds_saree_scpt_bottle 
    SCPT ds_saree_scpt_winerack 
    ACTI _ds_saree_vsva_winerack 
    MISC _ds_saree_vsva_skey 
    STAT _ds_saree_vsva_crate 
    CONT barrel_01 
    CONT _ds_saree_vsva_barrel01 
barrel_01 is still listed, you see, and I've still "changed" it everywhere in the world. Its changes may not be any
different than the original barrel, but picture the two following scenarios: 
# I'm playing around with objects and accidentally rename misc_com_bottle_05. Oops, what I wanted was a copy of that object, not to rename the original. So I make my copy, and rename the original to its correct original name. Well, tough luck mister, your mod still contains modified reference information for 991 instances of misc_com_bottle_05. The editor doesn't know well enough to understand that the changes you made "should have equaled zero", because two wrongs don't make a right. If you try this test, then go back to look at your "Details", you'll be astonished at all the crap you see on your list - changes to places you've never even heard of, and the size of your ESP will probably effectively double. Although the size of the ESP probably won't bother most people. They're not that big. 
# You think you change the object back to original, but you forget something critical. Now your mod is not only dirty, it's also harmful. 

The casual, lazy mod developer is going to look at the first scenario, shrug, and say, "Yeah, but so what? It is 
back like the original, right?" Not so for this mod developer. I'm a stickler for quality, and I managed to make a
pretty dirty mod when I was trying to be on my best behavior. Now imagine a mod developer who doesn't really care 
about how he names objects, or that he might be changing references to objects in 900 other places. Suddenly, I 
become just a little critical of downloading anyone else's mod. Is it safe? Is it clean? 

So, a plea to all of my fellow mod developers: First, and probably most important, make your own objects! Do not 
modify the originals! And please, if you can spare the tiny bit of extra effort, name your objects something distinct
and obvious, and keep a running list of all the new objects in your mod. (This makes debugging SO much easier!) 

Second, before you ever distribute your mod, go to the Details list, and see just how clean that ESP really is! 
If you can account for everything on that list, then you're a-okay. But if you find you have scads and scads of 
objects that aren't yours and you thought you hadn't modified (or suddenly realize you shouldn't have!) then please,
at least consider telling people in advance.