|
| 1 | +--- |
| 2 | +title: Using Lawnmower to Delete Clipping Groundcover |
| 3 | +aliases: |
| 4 | + - Using Lawnmower to Delete Clipping Groundcover |
| 5 | + - Lawnmower Groundcover Tutorial |
| 6 | +tags: |
| 7 | + - Groundcover |
| 8 | + - Lawnmower |
| 9 | + - Tutorials |
| 10 | + - Grass |
| 11 | + - Cleaning-Mods |
| 12 | +description: How to use `lawnmower.py` script to clean groundcover mods of excess grass |
| 13 | +parent: "[[the-lawnmower|Lawnmower]]" |
| 14 | +related articles: |
| 15 | + - "[[the-lawnmower|Lawnmower]]" |
| 16 | +--- |
| 17 | +## About |
| 18 | + |
| 19 | +> [!infobox|n-th] |
| 20 | +> |
| 21 | +> ## Lawnmower Groundcover Tutorial |
| 22 | +> |
| 23 | +> ![[lawnmower-for-morrowind-logo.webp|center]] |
| 24 | +> |
| 25 | +> ### Tutorial Info |
| 26 | +> |
| 27 | +> | Type | Name | |
| 28 | +> | --- | --- | |
| 29 | +> | **Requirements** | - [The Lawnmower](https://www.nexusmods.com/morrowind/mods/53034)<br>- [Tes3conv](https://github.com/Greatness7/tes3conv)<br>- [Python 3.5 or later](https://www.python.org/)<br>- [Tes3cmd](https://modding-openmw.com/mods/tes3cmd/) (optional)<br>- [TESTool](https://www.nexusmods.com/morrowind/mods/47473) (optional) | |
| 30 | +> | **Tutorial Files** | Any groundcover plugin you like that has not already had Lawnmower ran on it (the mod description will likely state whether this is the case) | |
| 31 | +
|
| 32 | +This tutorial covers how to use [[the-lawnmower|The Lawnmower]] tool to clean [[guides/groundcover/index|groundcover]] mods of excess grass - specifically, grass which clips through or is hidden under other objects. |
| 33 | + |
| 34 | +![[the-lawnmower#^2eccab|clean]] |
| 35 | + |
| 36 | +However, for the purposes of this tutorial we will only be focusing on the titular **Lawnmower**. |
| 37 | + |
| 38 | +### Goals |
| 39 | + |
| 40 | +By the end of this tutorial, you should be able to: |
| 41 | + |
| 42 | +1. Run `lawnmower.py` Python script on a groundcover plugin |
| 43 | +2. Compare a groundcover plugin against multiple mods ('chaining') |
| 44 | +3. Understand how to use the 'autoclean' plugins to increase the accuracy of The Lawnmower |
| 45 | +4. Clean the patched groundcover plugin |
| 46 | + |
| 47 | +### Prerequisites |
| 48 | + |
| 49 | +> [!Info|right wm-sm txt-s] Installing Python |
| 50 | +> Whilst it may seem daunting, installation is unremarkable on most platforms.[^1] |
| 51 | +> |
| 52 | +> See Python [BeginnersGuide / Download](https://wiki.python.org/moin/BeginnersGuide/Download) for help. |
| 53 | +
|
| 54 | +In addition to downloading The Lawnmower (tools only), the tool also requires that you have [Tes3conv](https://github.com/Greatness7/tes3conv) and [Python](https://www.python.org/) installed. |
| 55 | + |
| 56 | +Copy `tes3conv.exe` to your Morrowind `Data Files` folder, or install it using a mod manager. |
| 57 | + |
| 58 | +Likewise, copy `lawnmower.py` from The Lawnmower to `Data Files` or install it with a mod manager. |
| 59 | + |
| 60 | +## Running the Script |
| 61 | + |
| 62 | +```mermaid |
| 63 | +flowchart LR |
| 64 | +
|
| 65 | + A("python") --> B("lawnmower.py") --> C("Morrowind.esm") --> D("Rem_AC.esp") --> E("Rem_AC_out.esp") |
| 66 | + A ~~~ |"Python"| A |
| 67 | + B ~~~ |"the Python script to execute"| B |
| 68 | + C ~~~ |"Input"| C |
| 69 | + D ~~~ |"Groundcover"| D |
| 70 | + E ~~~ |"Output"| E |
| 71 | + |
| 72 | +
|
| 73 | +``` |
| 74 | + |
| 75 | +`lawnmower.py` is a Python script. To run it, open a command-line terminal (e.g., Windows Powershell) and enter `python lawnmower.py`, followed by three plugin names: |
| 76 | + |
| 77 | +1. **Input**: The plugin to compare the groundcover against, e.g., `Morrowind.esm`. |
| 78 | +2. **Groundcover mod**: The groundcover plugin Lawnmower will trim, e.g., `Rem_AC.esp` |
| 79 | +3. **Output**: The name you give to the trimmed groundcover mod, e.g., `Rem_AC_out.esp` |
| 80 | + - Output can be named anything you like, as long as it ends with the extension `.esp` or `.esm`, e.g., `trimmed_mod.esm`. |
| 81 | + |
| 82 | +This would be entered as: |
| 83 | + |
| 84 | +``` |
| 85 | +python lawnmower.py Morrowind.esm Rem_AC.esp Rem_AC_out.esp |
| 86 | +``` |
| 87 | + |
| 88 | +Press <kbd>Enter</kbd> to execute the script, and Lawnmower will create the freshly trimmed groundcover plugin '`Rem_AC_out.esp`'. |
| 89 | + |
| 90 | +## Running Lawnmower Against Mutiple Plugins |
| 91 | + |
| 92 | +Also known as 'Chaining' - The steps taken above in [[lawnmower-tutorial#Running the Script|'Running the Script']] can be repeated by substituting different input plugins. |
| 93 | + |
| 94 | +For example, if you add a city overhaul mod which adds numerous buildings to cities (e.g., `cool cities.esp`, and you wish for your previous `Rem_AC_out.esp` to be trimmed of grass clipping through the new buildings, the command can be formatted like so: |
| 95 | + |
| 96 | +``` |
| 97 | +python lawnmower.py "cool cities.esp" Rem_AC_out.esp "Rem_AC_out 2.esp" |
| 98 | +``` |
| 99 | + |
| 100 | +```mermaid |
| 101 | +flowchart LR |
| 102 | +
|
| 103 | + A("python") --> B("lawnmower.py") --> C("cool cities.esp") --> D("Rem_AC_out.esp") --> E("Rem_AC_out 2.esp") |
| 104 | + A ~~~ |"Python"| A |
| 105 | + B ~~~ |"the Python script to execute"| B |
| 106 | + C ~~~ |"Input"| C |
| 107 | + D ~~~ |"Groundcover"| D |
| 108 | + E ~~~ |"Output"| E |
| 109 | + |
| 110 | +
|
| 111 | +``` |
| 112 | + |
| 113 | +This can be repeated for any plugins you wish to compare the groundcover against, and even turned into a <abbr title="Batch File">BAT file</abbr> to be reused. |
| 114 | + |
| 115 | +> [!tip|txt-s] Using Lawnmower with your Entire Mod-List |
| 116 | +> Some tools for [[modding-tools/merging-plugins/index|merging plugins]], such as [[habasi|Habasi]], can generate a single merged plugin of your entire mod list. This merged plugin can be used as the `input` plugin for Lawnmower, saving you the trouble of running the script on individual mods. |
| 117 | +
|
| 118 | +## Utilizing Autoclean Plugins |
| 119 | + |
| 120 | +Autoclean plugins can be used to increase the accuracy of Lawnmower in detecting clipping groundcover. |
| 121 | + |
| 122 | +Lawnmower comes packaged with two autoclean plugins: |
| 123 | + |
| 124 | +- `autoclean_cities_vanilla.esp`: For Vvardenfell cities |
| 125 | +- `autoclean_cities_TR.ESP`: For [Tamriel Rebuilt](https://www.tamriel-rebuilt.org/) cities |
| 126 | + |
| 127 | +These plugins utilize the invisible marker meshes from [[the-lawnmower#Grassblocker|Grassblocker]], which `lawnmower.py` treats as objects when detecting whether grass is clipping. The plugins place these meshes in common areas where unwanted grass is often generated by [[mesh-gen|Mesh Generator]], but which otherwise won't be detected by `lawnmower.py` unless an object covers the area - i.e., a Grassblocker mesh. Mod makers can also create Lawnmower autoclean patches for their own mods using Grassblocker. |
| 128 | + |
| 129 | +The syntax for cleaning a groundcover plugin with an autoclean plugin is the same as any other: |
| 130 | + |
| 131 | +``` |
| 132 | +python lawnmower.py autoclean_cities_vanilla.esp "my grassmod.esp" "my grassmod_out.esp" |
| 133 | +``` |
| 134 | + |
| 135 | +## Advanced - Cleaning the Plugin |
| 136 | + |
| 137 | +The caveat to The Lawnmower is that it does not truly delete the grass references it detects. |
| 138 | + |
| 139 | +Instead, it moves their coordinates to `X: 0`, `Y: 0`, `Z: -20,000`, far below the surface of the game world. As groundcover plugins contain tens of thousands of references, these moved references are still taking up file space, even if they are never encountered in-game. Deleting these will not improve performance markedly, but it can make analyzing the output plugin easier. |
| 140 | + |
| 141 | +With a couple of extra steps, the reference count of the output plugin can be greatly reduced. |
| 142 | + |
| 143 | +> [!Note|txt-s right wm-sm] Note on Performance Impact |
| 144 | +> Deleting the references likely will not offer any noticeable performance gain, beyond marginally improving plugin load speed upon launching the game. |
| 145 | +> |
| 146 | +> However, it does make it easier to analyze the output plugin later by removing redundant data, for example: |
| 147 | +> |
| 148 | +> - Viewing modified cells in [[CSSE]] or [[modding-tools/low-level-editors/index|low-level editors]]: Cells containing only grass moved by Lawnmower will no longer appear as modified. |
| 149 | +> - Viewing a text representation of the plugin created by Tes3cmd `dump`, Tes3conv JSON or [[deltaplugin|DeltaPlugin]] YAML: Cleaning the plugin 'declutters' it so redundant data does not clutter the results. |
| 150 | +
|
| 151 | +Cleaning the output plugin of redundant `CELL` references involves two steps: |
| 152 | + |
| 153 | +1. Delete the moved grass with [[tes3cmd|Tes3cmd]]. |
| 154 | +2. Clean the plugin of any empty cells with [[testool|TESTool]]. |
| 155 | + |
| 156 | +The second step is useful for instances where Lawnmower has removed all grass from a cell, leaving an empty `CELL` record. |
| 157 | + |
| 158 | +### Step 1 - Tes3cmd |
| 159 | + |
| 160 | +Thankfully, the moved references have one unique thing in common: their coordinates have all been moved to `Z: -20,000`. |
| 161 | + |
| 162 | +The following Tes3cmd `delete` command will delete all the moved references: |
| 163 | + |
| 164 | +```tile="tes3cmd 'delete' command" |
| 165 | +tes3cmd delete --instance-match "Z\:-20000" <path-to-plugin> |
| 166 | +``` |
| 167 | + |
| 168 | +Replace `<path-to-plugin>` with your plugin name. |
| 169 | + |
| 170 | +### Step 2 - TESTool |
| 171 | + |
| 172 | +TESTool can clean empty cells which are otherwise not considered by Tesecmd as 'junk cells'. |
| 173 | + |
| 174 | +Simply run TESTool `Clean ESP/ESM files` on the output plugin. |
| 175 | + |
| 176 | +## Further Reading |
| 177 | + |
| 178 | +- [[the-lawnmower|The Lawnmower]] |
| 179 | +- [[mesh-gen|Mesh Generator]] |
| 180 | +- [[habasi|Habasi]] |
| 181 | + |
| 182 | +[^1]: "Python for Beginners: Installing", Python.org, accessed August 24, 2024, https://www.python.org/about/gettingstarted/ |
0 commit comments