[RELz] tes3cmd, a tool for editing TES3 plugins, and much mo

Post » Sun Aug 25, 2013 6:05 pm

tes3cmd is a command line tool for batch operations on Morrowind (TES3) plugins.

It currently lives http://code.google.com/p/mlox/wiki/Tes3cmd, where you can find instructions for download/install/usage and so on.

A new version is coming soon with bugfixes and new features.

tes3cmd allows you to do various things, like:
  • Clean plugins (probably one of the most useful features for regular users)
  • Generate a "multipatch" for leveled lists and more
  • Convert a plugin or savegame to readable text (handy for understanding plugins)
  • Global search and replace
  • Global modification of records via small scripts written in Perl
  • Much, much more

Previous threads: http://www.gamesas.com/topic/934107-relz-tes3cmd-a-small-tool-for-modifying-tes3-plugins/, http://www.gamesas.com/topic/1395562-relz-tes3cmd-a-small-tool-for-modifying-tes3-plugins/.
User avatar
Phillip Brunyee
 
Posts: 3510
Joined: Tue Jul 31, 2007 7:43 pm

Post » Sun Aug 25, 2013 9:07 pm

Out of curiosity, what does not work changing directly light_dwrv_neon00 values from the Light tab in CS?
User avatar
Nicole Coucopoulos
 
Posts: 3484
Joined: Fri Feb 23, 2007 4:09 am

Post » Sun Aug 25, 2013 2:27 pm

Dwemer blinking lights is not 100% compatible with light mods but instead of making patches I wanna make bat files to change values in "Dwemer blinking lights.esp".
User avatar
Marina Leigh
 
Posts: 3339
Joined: Wed Jun 21, 2006 7:59 pm

Post » Sun Aug 25, 2013 5:52 am

The subject of advanced regular expression matching came up in another thread, so I thought I'd post more here.

The example was in reference to:
(Note: \B in this post should be lowercase b, forum software is mangling stuff, it also converted some of them into smileys. Gah!)

Here's an attempt to explain that stuff:

The first thing to note is that potion IDs have a pattern to them. You can list all the IDs like this:

tes3cmd dump --no-banner --list --type alch Morrowind.esm

On linux, it's even handier to be able to sort the output by piping to "sort", but in any case, notice that potion IDs start with "p_" or "potion_". And in the case when it starts with "p_" it ends with "_b", "_c", "_e", "_q", or "_s". So, the idea one might start with is that you can construct a pattern that will reliably match all the potion IDs. It turns out you can, but I only found that out after confirming it with a test.

To match what we have observed so far, we would write a pattern like this:

name:(potion_|p_.+?_[bceqs]\/cool.png' class='bbc_emoticon' alt='B)' />

We know that in a cell, object reference names are preceeded with "name:" so that will start our pattern. The parentheses and vertical bar are used to specify alternative patterns. And \b matches a word boundary (such as between the end of a word and a space that follows).
So the pattern above matches potion IDs that begin with either "potion_" or "p_" and in the latter case, when ended by one of [bceqs].

Further observation shows that some potion IDs end in "_unique" instead of the [bceqs], so we add that to our pattern as an altenative:

name:(potion_|p_.+?_(unique|[bceqs])\/cool.png' class='bbc_emoticon' alt='B)' />

There is also the potion "p_vintagecomberrybrandy1" so we can add that as yet another alternative to the stuff that comes after "p_":

name:(potion_|p_(vintage|.+?_(unique|[bceqs])\/cool.png' class='bbc_emoticon' alt='B)' />

So, let's test our pattern and see if any other record types (not ALCH) match:

tes3cmd dump --id "^(potion_|p_(vintage|.+?_(unique|[bceqs])$))" --no-banner --list Morrowind.esm

In this case I replaced "name:" with "^" which anchors the patter to the start of the string. If our pattern was chosen correctly, we should only see objects of type ALCH matching, and that is what we see. This confirms we have chosen a good pattern for matching potion IDs.

Note that "." by itself means match any character. ".+" means match any character repeated one or more times. and ".+?" means match any character repeated one or more times but only with the minimum number of characters. Normally "*" and "+" are greedy, which means they match repeated regular expressions of the longest length, but adding the question mark at the end of a regular expression means to do a non-greedy or minimal match.

Continuing on, we want a pattern that matches a non-zero X/Y angle. This is what I propose:

x_angle:[0.]*[^0. ]

[0.]* - matches any string containing only "0" and ".", repeated zero or more times. Note that "." inside brackets just matches the period.
[^0. ] - matches any string that does not contain "0", "." or " " (space).

So if any number other than 0 appears after the "x_angle:" and before a space, we should have a match.

We can add an alternative to also match for the y_angle:

(x_angle:[0.]*[^0. ]|y_angle:[0.]*[^0. ])

Putting things together we have:
(?s)name:(potion_|p_(vintage|.+?_(unique|[bceqs])\ /cool.png' class='bbc_emoticon' alt=':cool:' />).*(x_Angle:[0.]*[^0. ]|y_Angle:[0.]*[^0. ])
The initial (?s) is a way to add options to how the regular expression works. In this case the "s" means to treat the string we are matching as a single-line, or in other words "." is not special. Normally "." is special in that it does not match the newline character at the end of a line. We use this as the string that represents an object reference is a multi-line string, where each line is a different sub-record and we want to match multiple subrecords (the NAME, which contains the potion ID and DATA which contains the Angles).

Regular expressions are a deep subject, and they can be confusing. Entire books have been written about them. I think I covered most of what is needed to understand the example I gave, but if anyone wants more info, let me know.

(And sorry about the smileys and \B crap, they should all be backslash-lowercase "b")
User avatar
des lynam
 
Posts: 3444
Joined: Thu Jul 19, 2007 4:07 pm

Post » Sun Aug 25, 2013 8:14 pm

What exactly does this message mean. After I cleaned my mod with tes3cmd, Construction Set gave me this warning when I load it up:
MovedRef (16791335) and LoadRef(16785377) mismatch in load for Cell "Ald-ruhn' (-3, 6).

Everything looks the same, but I'm wondering what exactly tes3cmd might have done (since I don't see a change).
User avatar
Klaire
 
Posts: 3405
Joined: Wed Sep 27, 2006 7:56 am

Post » Sun Aug 25, 2013 12:18 pm

That looks to me like a moved reference was removed from a cell without the corresponding MVRF part. I don't think this should happen with the normal "clean" command. Can you tell me the exact command line you used and the version number of tes3cmd you are using? (If you aren't using 0.37s, that might be related to the problem). Would it be possible for you to send me the plugin so I could look at it?

Basically, when you move an object in a cell that was placed there by one of your plugin's masters, you end up with two groups of sub-records in the CELL, the FRMR group, which is the object reference and associated sub-records, and a preceeding group for the MVRF (moved reference) sub-records. I put some code into tes3cmd in 0.37s to avoid cleaning referencs that have been moved, so if you are using that version, it looks like I may need to re-investigate that situation.
User avatar
Guinevere Wood
 
Posts: 3368
Joined: Mon Dec 04, 2006 3:06 pm

Post » Sun Aug 25, 2013 1:00 pm

is there a list with mods, which must not be cleaned or else they won't work? I remember something similar for oblivion mods. this program sounds awesome btw.
User avatar
Assumptah George
 
Posts: 3373
Joined: Wed Sep 13, 2006 9:43 am

Post » Sun Aug 25, 2013 5:48 pm

Unless there is some bug I have not found yet, tes3cmd should be safe to clean all mods. The description of the cleaning operations can be http://code.google.com/p/mlox/wiki/Tes3cmd#clean_-_Clean_plugins_of_Evil_GMSTs,_junk_cells,_and_more (Look for the part starting: 'The goal of the "clean" command is that it should always be safe ...'. So, at least in theory, it only does cleaning operations known to be safe.

If you read in a readme that it is not safe to clean a mod, I suspect that was written in reference to using TESTOOL, which may possibly have some bugs remaining with respect to cleaning, although I do not know of any off the top of my head.
tes3cmd also does automatically skip cleaning some plugins (such as the Bethesda masters). This is just an additional safety precaution, although there is a way to clean them if you really wanted to.
User avatar
Quick Draw
 
Posts: 3423
Joined: Sun Sep 30, 2007 4:56 am

Post » Sun Aug 25, 2013 8:57 am

I am using .37p. I updated to the latest one and no problem occurred.
However, I did figure out what object the old one was talking about. I re-cleaned my mod with .37p to watch what it did and at one point it mentioned deleting duplicate ashland rocks. I had just recently merged into my mod a small plugin that moved some rocks from vanilla Ald'ruhn. Since my main mod had moved those long ago, I guess tes3cmd considered them duplicates. But 37s doesn't make CS complain so I guess that's solved.

If you would still like to see the esp, I'll be glad to pm it to you though.
User avatar
Richus Dude
 
Posts: 3381
Joined: Fri Jun 16, 2006 1:17 am

Post » Sun Aug 25, 2013 6:01 am


gonna use this tool from now on. have already tried it out and the multipatch feature is working without problems, but I can't seem to get the cleaner working. it says: "no plugins to process". exe is located in data files, I've also tried adding some options but with no success.
User avatar
Angus Poole
 
Posts: 3594
Joined: Fri Aug 03, 2007 9:04 pm

Post » Sun Aug 25, 2013 12:19 pm

No, that's all right. It sounds like everything is okay with 0.37s now.
User avatar
Damian Parsons
 
Posts: 3375
Joined: Wed Nov 07, 2007 6:48 am

Post » Sun Aug 25, 2013 8:49 pm

You can do cleaning in some different ways on the command line.

To clean one plugin:
tes3cmd clean myplugin.esp

To clean multiple plugins, using wildcards:
tes3cmd clean *.es[mp]
(You may want to use the --ignore-plugin if this cleans some plugins you don't want cleaned).

If you want to clean all plugins in your load order, create a multipatch, reset the dates of your bethesda masters to their original dates and synchronize plugins to masters:
tes3cmd fixit
User avatar
clelia vega
 
Posts: 3433
Joined: Wed Mar 21, 2007 6:04 pm

Post » Sun Aug 25, 2013 9:41 pm


cool, got it. I was using the wrong parameter. a lot of false entries in my mods died that day and it felt geeeewd x_x
User avatar
Bad News Rogers
 
Posts: 3356
Joined: Fri Sep 08, 2006 8:37 am

Post » Sun Aug 25, 2013 5:31 pm

These commands dont work

tes3cmd header --author "+ and friends" "plugin.esp"tes3cmd header --description "+\nVersion: 1.0" "plugin.esp"
User avatar
Calum Campbell
 
Posts: 3574
Joined: Tue Jul 10, 2007 7:55 am

Post » Sun Aug 25, 2013 9:59 pm

Oops, I broke them in a recent change to handle those fixed width fields. They'll be fixed in the next release. Hopefully, not in the far distant future.
User avatar
.X chantelle .x Smith
 
Posts: 3399
Joined: Thu Jun 15, 2006 6:25 pm

Post » Sun Aug 25, 2013 11:39 am

Im trying to add sound to a light and I thought this
tes3cmd modify --type ligh --exact-id light_sotha_lantern --run "$R->append(LIGH::SNAM->new({soundID=>'Power light 50'}));$R->{_modified_}=1;" light_mod.esp
should work but I get error messages.
User avatar
Eduardo Rosas
 
Posts: 3381
Joined: Thu Oct 18, 2007 3:15 pm

Post » Sun Aug 25, 2013 3:46 pm


I think this should work:
tes3cmd modify --type ligh --exact-id light_sotha_lantern --run "$R-&--#62;append(LIGH::SNAM-&--#62;new({sound_id=&--#62;'Power light 50'}));$R-&--#62;{_modified_}=1;" test_ligh.esp
Note that the field name ("sound_id") you give should all be lowercase, and there is an underscore "_" in it.
I'll look into making future version more robust about doing a caseless match on the field name.
User avatar
Rhysa Hughes
 
Posts: 3438
Joined: Thu Nov 23, 2006 3:00 pm

Post » Sun Aug 25, 2013 1:20 pm

ok, been having a hard time with this for a long time to even get it up and running.
ive installed the standalone exe to my data files, went into my start menu, typed in run, in the cmd screen what do i do? i type cd all it does is just show my oringinal location right below it without letting me change the location.
User avatar
Lauren Graves
 
Posts: 3343
Joined: Fri Aug 04, 2006 6:03 pm

Post » Sun Aug 25, 2013 1:41 pm

That is understandable if you are not familiar with command line programs. tes3cmd does not come with an easy to use GUI.

If you start up a windows command line Start->Run Type: "cmd", then hit Enter. This gives you a command line window.
There should be a printed prompt in the window showing your current directory location.
You can change your drive letter by typing the new drive to change to and hitting Enter (e.g.: C: )
You can change directory by typing "cd \path\to\new\directory" and hitting Enter.
When the prompt indicates you are in the directory where you want to be, you can execute commands that operate on files there.

Hope that helps a little. I'm not really a Windows user, and I know I'm not always a good explainer.
User avatar
Nikki Hype
 
Posts: 3429
Joined: Mon Jan 01, 2007 12:38 pm

Post » Sun Aug 25, 2013 9:59 am

An easy way to start using a command line program is to make a text file in the same folder as the program, write your commands (one per line) in the file and change extension of the file to bat. When you run the bat file a command line window will appear and commands it contains will be executed. Command line window will close when all commands are executed. To prevent it from closing so that you can see if there were any errors add pause to the end of the bat file. To comment a line so it wont be executed add two colons in front of it.
User avatar
Ice Fire
 
Posts: 3394
Joined: Fri Nov 16, 2007 3:27 am

Post » Sun Aug 25, 2013 8:20 am

ok im confused now. when i open cmd my drive is C:Users\etc. So i dont need to change the drive, but when i add "cd\path\to\new\directory" all it says The system cannot find the path specified.

ok so i have the standalone exe and downloaded into my morrowind data files. im getting the "i see the box for a second before it disappears".

First off do i have the correct version and do i need soemthign else as well? Do i need ot have the program downloaded to a different file?

Im running with win764bit and tbh im just trying to use this to fix 1 freaking script problem im having.
User avatar
Alisia Lisha
 
Posts: 3480
Joined: Tue Dec 05, 2006 8:52 pm

Post » Sun Aug 25, 2013 5:30 pm

There should be a space between the "cd" and the following path.

Are you clicking on the tes3cmd.exe icon? You're not supposed to do that. It's a command line program only.

All you need is tes3cmd.exe, and it should go in the directory where you plan to use it. You could install it some place in your %PATH%, but that's a more advanced step.
User avatar
Horror- Puppe
 
Posts: 3376
Joined: Fri Apr 13, 2007 11:09 am

Post » Sun Aug 25, 2013 9:26 pm

Find cmd.exe in your windows folder, create shortcut to it. Open shortcut's properties, delete working folder so its blank. Copy the shortcut to any folder and run it to open command line in that folder.
User avatar
Damien Mulvenna
 
Posts: 3498
Joined: Wed Jun 27, 2007 3:33 pm

Post » Sun Aug 25, 2013 4:59 pm

Or... hold down shift, right click on folder, choose "Command Prompt" (at least on Win7)
User avatar
Lynne Hinton
 
Posts: 3388
Joined: Wed Nov 15, 2006 4:24 am

Post » Sun Aug 25, 2013 5:18 pm


I love that trick!
User avatar
Lizbeth Ruiz
 
Posts: 3358
Joined: Fri Aug 24, 2007 1:35 pm

Next

Return to III - Morrowind