Skip to content

Content: add Lawnmower Tutorial #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
182 changes: 182 additions & 0 deletions mmw-content/guides/groundcover/lawnmower-tutorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
---
title: Using Lawnmower to Delete Clipping Groundcover
aliases:
- Using Lawnmower to Delete Clipping Groundcover
- Lawnmower Groundcover Tutorial
tags:
- Groundcover
- Lawnmower
- Tutorials
- Grass
- Cleaning-Mods
description: How to use `lawnmower.py` script to clean groundcover mods of excess grass
parent: "[[the-lawnmower|Lawnmower]]"
related articles:
- "[[the-lawnmower|Lawnmower]]"
---
## About

> [!infobox|n-th]
>
> ## Lawnmower Groundcover Tutorial
>
> ![[lawnmower-for-morrowind-logo.webp|center]]
>
> ### Tutorial Info
>
> | Type | Name |
> | --- | --- |
> | **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) |
> | **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) |

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.

![[the-lawnmower#^2eccab|clean]]

However, for the purposes of this tutorial we will only be focusing on the titular **Lawnmower**.

### Goals

By the end of this tutorial, you should be able to:

1. Run `lawnmower.py` Python script on a groundcover plugin
2. Compare a groundcover plugin against multiple mods ('chaining')
3. Understand how to use the 'autoclean' plugins to increase the accuracy of The Lawnmower
4. Clean the patched groundcover plugin

### Prerequisites

> [!Info|right wm-sm txt-s] Installing Python
> Whilst it may seem daunting, installation is unremarkable on most platforms.[^1]
>
> See Python [BeginnersGuide / Download](https://wiki.python.org/moin/BeginnersGuide/Download) for help.

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.

Copy `tes3conv.exe` to your Morrowind `Data Files` folder, or install it using a mod manager.

Likewise, copy `lawnmower.py` from The Lawnmower to `Data Files` or install it with a mod manager.

## Running the Script

```mermaid
flowchart LR

A("python") --> B("lawnmower.py") --> C("Morrowind.esm") --> D("Rem_AC.esp") --> E("Rem_AC_out.esp")
A ~~~ |"Python"| A
B ~~~ |"the Python script to execute"| B
C ~~~ |"Input"| C
D ~~~ |"Groundcover"| D
E ~~~ |"Output"| E


```

`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:

1. **Input**: The plugin to compare the groundcover against, e.g., `Morrowind.esm`.
2. **Groundcover mod**: The groundcover plugin Lawnmower will trim, e.g., `Rem_AC.esp`
3. **Output**: The name you give to the trimmed groundcover mod, e.g., `Rem_AC_out.esp`
- Output can be named anything you like, as long as it ends with the extension `.esp` or `.esm`, e.g., `trimmed_mod.esm`.

This would be entered as:

```
python lawnmower.py Morrowind.esm Rem_AC.esp Rem_AC_out.esp
```

Press <kbd>Enter</kbd> to execute the script, and Lawnmower will create the freshly trimmed groundcover plugin '`Rem_AC_out.esp`'.

## Running Lawnmower Against Mutiple Plugins

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.

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:

```
python lawnmower.py "cool cities.esp" Rem_AC_out.esp "Rem_AC_out 2.esp"
```

```mermaid
flowchart LR

A("python") --> B("lawnmower.py") --> C("cool cities.esp") --> D("Rem_AC_out.esp") --> E("Rem_AC_out 2.esp")
A ~~~ |"Python"| A
B ~~~ |"the Python script to execute"| B
C ~~~ |"Input"| C
D ~~~ |"Groundcover"| D
E ~~~ |"Output"| E


```

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.

> [!tip|txt-s] Using Lawnmower with your Entire Mod-List
> 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.

## Utilizing Autoclean Plugins

Autoclean plugins can be used to increase the accuracy of Lawnmower in detecting clipping groundcover.

Lawnmower comes packaged with two autoclean plugins:

- `autoclean_cities_vanilla.esp`: &nbsp; For Vvardenfell cities
- `autoclean_cities_TR.ESP`: &nbsp; For [Tamriel Rebuilt](https://www.tamriel-rebuilt.org/) cities

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.

The syntax for cleaning a groundcover plugin with an autoclean plugin is the same as any other:

```
python lawnmower.py autoclean_cities_vanilla.esp "my grassmod.esp" "my grassmod_out.esp"
```

## Advanced - Cleaning the Plugin

The caveat to The Lawnmower is that it does not truly delete the grass references it detects.

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.

With a couple of extra steps, the reference count of the output plugin can be greatly reduced.

> [!Note|txt-s right wm-sm] Note on Performance Impact
> Deleting the references likely will not offer any noticeable performance gain, beyond marginally improving plugin load speed upon launching the game.
>
> However, it does make it easier to analyze the output plugin later by removing redundant data, for example:
>
> - 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.
> - 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.

Cleaning the output plugin of redundant `CELL` references involves two steps:

1. Delete the moved grass with [[tes3cmd|Tes3cmd]].
2. Clean the plugin of any empty cells with [[testool|TESTool]].

The second step is useful for instances where Lawnmower has removed all grass from a cell, leaving an empty `CELL` record.

### Step 1 - Tes3cmd

Thankfully, the moved references have one unique thing in common: their coordinates have all been moved to `Z: -20,000`.

The following Tes3cmd `delete` command will delete all the moved references:

```tile="tes3cmd 'delete' command"
tes3cmd delete --instance-match "Z\:-20000" <path-to-plugin>
```

Replace `<path-to-plugin>` with your plugin name.

### Step 2 - TESTool

TESTool can clean empty cells which are otherwise not considered by Tesecmd as 'junk cells'.

Simply run TESTool `Clean ESP/ESM files` on the output plugin.

## Further Reading

- [[the-lawnmower|The Lawnmower]]
- [[mesh-gen|Mesh Generator]]
- [[habasi|Habasi]]

[^1]: "Python for Beginners: Installing", Python.org, accessed August 24, 2024, https://www.python.org/about/gettingstarted/
2 changes: 2 additions & 0 deletions mmw-content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Completed articles so far include:
- [[esp-replacer-patch-beginner-tutorial|ESP-Replacer Patch Beginner Tutorial]]
- [[morrowind-interiors-project|Morrowind Interiors Project]]
- [[simple-texture-animation-in-blender|Simple Texture Animation in Blender]]
- [[the-lawnmower|Lawnmower]]
- [[lawnmower-tutorial|Lawnmower Groundcover Tutorial]]

Work-in-progress articles:
- [[creating-a-patch-for-an-esp|Creating a Patch for an ESP]]
Expand Down
91 changes: 85 additions & 6 deletions mmw-content/modding-tools/generating-groundcover/the-lawnmower.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,103 @@ title: The Lawnmower
aliases:
- The Lawnmower
- Lawnmower
- Weedwhacker
- Grassclipper
- Grassblocker
tags:
- Lawnmower
description:
- Cleaning-Mods
- Groundcover
description: A tool for cleaning groundcover mods of excess grass using Python scripts and Tes3conv.
parent: "[[modding-tools/generating-groundcover/index|Generating Groundcover]]"
related articles:
- "[[lawnmower-tutorial|Lawnmower Groundcover Tutorial]]"
---

![[lawnmower-for-morrowind-banner.webp|sban]]

![[maintenance-expand-article#^6fc39d|clean]]

## About

> [!infobox]
> [!infobox|n-th]
>
> ## The Lawnmower
>
> %%![[insert image]]%%
> ![[lawnmower-for-morrowind-logo.webp]]
>
> ### Table Heading
> ### Details
>
> | Type | Name |
> | --- | --- |
> | Row | Row |
> | Row | Row |
> | **Links** | - [NexusMods](https://www.nexusmods.com/morrowind/mods/53034)<br>- [Github](https://github.com/acidzebra/lawnmower) |
> | **Requirements** | - [Python]()<br>- [[tes3conv\|Tes3conv]] |

**The Lawnmower** is a tool for cleaning [[guides/groundcover/index|groundcover]] mods of excess grass using Python scripts and Tes3conv.

> [!NOTE|clean no-t] %%outline of lawnmower tools%%
> The Lawnmower actually comprises four separate tools:
>
> - **[[the-lawnmower#Lawnmower|'Lawnmower']]**: removes clipping and unwanted grass
> - **[[the-lawnmower#Weedwhacker|'Weedwhacker']]**: thins out grass
> - **[[the-lawnmower#Grassclipper|'Grassclipper']]**: fixes floating grass
> - **[[the-lawnmower#Grassblocker|'Grassblocker']]**: makes your mod autoclean-compatible
^2eccab

## Lawnmower

`lawnmower.py` will take an input esp/esm file, a grass mod, and an output file as commandline arguments. It will compare them and if there is any clipping detected between the grass and objects in the mod, it will move the grass out of sight.

Moved grass references have their coordinates set to `Z: 0`, `X: 0`, `Z: -20,000`.

**Usage:**
```
python lawnmower.py "Morrowind.esm" "AesAdGrass_AC.esp" "AesAdGrass_AC_out.esp"
```

## Weedwhacker

`weedwhacker.py` takes a groundcover mod, an output plugin and a number between 1-99 as its arguments. It will reduce the grass references in the output plugin as a percentage according to the number chosen.

**Usage:**
```
python weedwhacker.py "mygrassmod.esp" "mygrassmod_out.esp" 50
```

## Grassclipper

`grassclipper.py` takes two groundcover mods as input, comparing both for matching cells and overwriting the cells of mod A with those of mod B, then saving the combined output.

**Grassclipper** is mainly intended for mod makers to speed up the process of creating groundcover patches after generating grass with [[mesh-gen|Mesh Generator]].

**Usage:**
```
python grassclipper.py "mygrassmod.esp" "mygrassmod_patch.esp" "mygrassmod_combined.esp"
```

> [!Warning]
> In order to work correctly, both groundcover mods must be generated using the same `.ini` configuration from Mesh Generator.

## Grassblocker

**Grassblocker**, rather than being a script, is a method of creating custom 'auto-clean' plugins that can improve the accuracy of `lawnmower.py`.

> [!caption|right wm-sm]
> ![[lawnmower-grassblocker-meshes-in-balmora.webp|wm-sm]]
> Grassblocker meshes in Balmora

This is achieved by utilizing the `grassblocker_` meshes included with Lawnmower:

- `grassblocker_small.nif`
- `grassblocker_medium.nif`
- `grassblocker_large.nif`
- `grassblocker_xl.nif`
- `grassblocker_xxl.nif`

These invisible marker meshes will appear in the Construction Set, but not in-game, and will be detected by `lawnmower.py` like any other reference when checking for grass which clips through other objects.

## Troubleshooting

**Linux**
> "This tool almost works on linux. I had to replace `tes3conv.exe` with `tes3conv` (which is in my $PATH) and remove the check that checks for the file present in the directory"
> \- DorsaiDonal, [Nexus mod page comments](https://www.nexusmods.com/morrowind/mods/53034?tab=posts), 29 November 2023, 10:42AM
21 changes: 15 additions & 6 deletions mmw-content/modding-tools/merging-plugins/habasi.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,31 @@ aliases:
tags:
- Habasi
- Combining-plugins
description:
description: Habasi is a command-line tool for merging multiple plugins into one.
parent: "[[modding-tools/merging-plugins/index|Merging Plugins]]"
related articles:
- "[[lawnmower-tutorial|Lawnmower Groundcover Tutorial]]"
- "[[modding-tools/merging-plugins/index|Merging Plugins]]"
---

![[maintenance-expand-article#^6fc39d|clean]]

## About

> [!infobox]
> [!infobox|n-th]
>
> ## Habasi
>
> %%![[insert image]]%%
> > [!caption|wfull txt-s]
> > ![[picture-of-habasi-from-uesp.webp|profile ws-med hs-med]]
> > (image credit: [UESP](https://en.uesp.net/wiki/File:MW-npc-Sugar-Lips_Habasi.jpg))
>
> ### Table Heading
> ### Details
>
> | Type | Name |
> | --- | --- |
> | Row | Row |
> | Row | Row |
> | **Links** | [NexusMods](https://www.nexusmods.com/morrowind/mods/53002)<br>[Github](https://github.com/alvazir/habasi/) |
> | **Requirements** | None |
> | **License** | [GNU GPLv3](https://github.com/alvazir/habasi/blob/master/LICENSE) |

**Habasi** is a command-line tool for merging multiple plugins into one.