SpringModEdit
Introduction
This is SpringModEdit: source:trunk/tools/SpringModEdit/
Essentially it is a utility for performing mass Lua operations on unit files. You can write a Lua script to modify units (all unit are stored in the Units table) and put it in the Procedures folder inside the SpringModEdit directory. When you fire SpringModEdit up, there will be a section on the lower-left called "Script Execution" where you can run the script.
Reliability
In my experience, SpringModEdit crashes quite often. However, it tends to be pretty obvious when it fails, and is fairly reliable once you get acquainted with its major quirks. The biggest ones I've listed below.
- Don't save back to the unit folder that you read from. This tends to cause SpringModEdit to crash and delete a random number of unit files. Instead, save to a different folder and copy them manually. It's best to do changes on a clean update of your SVN, just to make sure you don't lose any work.
- If a script doesn't work the first time, try it again. SpringModEdit tends to throw a false error when you first run a script, but it will work if you try it again.
Includes
At current, most of these were written by me, Evil4Zerggin. I can't make any promises to their quality, but if you commit your procedures, I'll try not to break them if I edit the includes.
csv.lua
source:trunk/tools/SpringModEdit/include/csv.lua
This is probably the most generally useful include. Basically it outputs a comma-separated values text of whatever tags you desire, for all units.
How to Use:
- Fire up SpringModEdit.
- Figure out what tags you want in the table.
- Inside the "Script Execution" box, put the following: GetsUnitCSV({"tag1", "tag2", ...})
Remember to put the tags in quotes. You'll probably want "unitname" as one of the tags.
- Hit Execute.
- If you get an error, hit Execute again.
- You should get a window with a pile of text in it. Copy and paste it into a text document and save it as a .csv.
- Open with Excel or equivalent.
Beyond this, there are some other features to the function:
- It accepts functions as well as tag names. If you write a Lua function, you can put it in the request table as well.
- There is an optional second argument, which allows you to filter the results with a function. Only units for which the function returns true are included in the table.
- There is an optional third argument, which defines the first line (titles) of the .csv . Without this argument, the output defaults to the tag names.
primitive.lua
source:trunk/tools/SpringModEdit/include/primitive.lua
Of particular interest:
- In this include I've written several functions for modifying tables. Why not modify the table directly, you ask? These functions automatically echo what they are changing, so you can see what you are changing. In addition, there is an argument doPreviewOnly, which allows you see what would change without actually doing it. This is good for making sure your procedure does what you think it does.