Skip to content

Commit 99c3586

Browse files
authored
Merge pull request #4632 from Bumber64/plant
Improve plants/plant plugin
2 parents 4f2e000 + ef9ee5c commit 99c3586

File tree

12 files changed

+1142
-336
lines changed

12 files changed

+1142
-336
lines changed

docs/Tags.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ for the tag assignment spreadsheet.
4242
- `labors <labors-tag-index>`: Tools that deal with labor assignment.
4343
- `map <map-tag-index>`: Tools that interact with the game map.
4444
- `military <military-tag-index>`: Tools that interact with the military.
45-
- `plants <plants-tag-index>`: Tools that interact with trees, shrubs, and crops.
45+
- `plants <plants-tag-index>`: Tools that interact with grass, trees, shrubs, and crops.
4646
- `stockpiles <stockpiles-tag-index>`: Tools that interact with stockpiles.
4747
- `units <units-tag-index>`: Tools that interact with units.
4848
- `workorders <workorders-tag-index>`: Tools that interact with workorders.

docs/about/Removed.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ petcapRemover
283283
=============
284284
Renamed to `pet-uncapper`.
285285

286+
.. _plants:
287+
288+
plants
289+
======
290+
Renamed to `plant`.
291+
286292
.. _resume:
287293

288294
resume

docs/changelog.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ Template for new versions:
5252
# Future
5353

5454
## New Tools
55+
- `plant`: (reinstated) tool for creating/growing/removing plants
5556

5657
## New Features
5758
- `tweak`: ``named-codices``: display book titles instead of a material description in the stocks/trade screens
59+
- `plant`: can now ``remove`` shrubs and saplings; ``list`` all valid shrub/sapling raw IDs; ``grow`` can make mature trees older; many new command options
5860

5961
## Fixes
6062
- `suspendmanager`: stop suspending single tile stair constructions
6163
- ``Gui::makeAnnouncement``, ``Gui::autoDFAnnouncement``: fix skipping index 0 when iterating reports vector
64+
- `regrass`: don't remove mud on regrass, consistent with vanilla behavior
6265
- `seedwatch`: display a limit of ``-`` instead of ``0`` for a seed that is present in inventory but not being watched
6366
- `tiletypes`: make aquifers functional when adding the ``aquifer`` property
6467
- `seedwatch`: do not include unplantable tree seeds in its status report
@@ -70,6 +73,7 @@ Template for new versions:
7073
- `blueprint`: capture track carving designations in addition to already-carved tracks
7174
- `changevein`: affect connected veins even outside of the selected map block
7275
- `logistics`: new ability to automatically forbid or claim items brought to a stockpile (or a dump within a stockpile)
76+
- `regrass`: now accepts numerical IDs for grass raws; ``regrass --list`` replaces ``regrass --plant ""``
7377
- `tiletypes`: performance improvements when affecting tiles over a large range
7478
- `tiletypes`: support for heavy aquifers
7579
- Dreamfort: add a full complement of beds and chests to both barracks
@@ -109,8 +113,8 @@ Template for new versions:
109113
- ``plugins.tiletypes.tiletypes_setTile``: can now accept a table with for access to previously unavailable options
110114
- ``dialogs.showYesNoPrompt``: extend options so the standard dialog can be used for `gui/confirm`-style confirmation prompts
111115

112-
113116
## Removed
117+
- `plants`: renamed to `plant`
114118
- ``gui.FramedScreen``: this class is now deprecated; please use ``gui.ZScreen`` and ``widgets.Window`` instead
115119

116120
# 50.13-r2

docs/plugins/plant.rst

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
plant
2+
=====
3+
4+
.. dfhack-tool::
5+
:summary: Grow and remove shrubs or trees.
6+
:tags: adventure fort armok map plants
7+
8+
Grow and remove shrubs or trees. Modes are ``list``, ``create``, ``grow``,
9+
and ``remove``. ``list`` prints a list of all valid shrub and sapling raw IDs.
10+
``create`` allows the creation of new shrubs and saplings. ``grow`` adjusts
11+
the age of saplings and trees, allowing them to grow instantly. ``remove`` can
12+
remove existing shrubs and saplings.
13+
14+
Usage
15+
-----
16+
17+
Provide a mode (including a ``plant_id`` for ``create``) followed by optional
18+
``pos`` arguments and options. The ``pos`` arguments can limit operation of
19+
``grow`` or ``remove`` to a single tile or a cuboid. ``pos`` should normally be
20+
in the form ``0,0,0``, without spaces. The string ``here`` can be used in place
21+
of numeric coordinates to use the position of the keyboard cursor, if active.
22+
23+
::
24+
25+
plant list
26+
27+
Prints a list of all shrub and sapling raw IDs for use with the other modes.
28+
Both numerical and string IDs are provided.
29+
30+
::
31+
32+
plant create <plant_id> [<pos>] [<options>]
33+
34+
Creates a new plant of the specified type at ``pos`` or the cursor position.
35+
The target must be a floor tile, consisting of soil, grass, ashes, or
36+
non-smooth muddy (layer, obsidian, or ore) stone. ``plant_id`` is not
37+
case-sensitive, but must be enclosed in quotes if spaces exist. (No unmodded
38+
shrub or sapling raw IDs have spaces.) A numerical ID can be used in place of a
39+
string. Use ``plant list`` for a list of valid IDs.
40+
41+
::
42+
43+
plant grow [<pos> [<pos>]] [<options>]
44+
45+
Grows saplings (including dead ones) into trees. Will default to all saplings
46+
on the map if no ``pos`` arguments are used. Saplings will die and fail to grow
47+
if they are blocked by another tree.
48+
49+
::
50+
51+
plant remove [<pos> [<pos>]] [<options>]
52+
53+
Remove plants from the map (or area defined by ``pos`` arguments). By default,
54+
it only removes invalid plants that exist on non-plant tiles (due to
55+
:bug:`12868`). The ``--shrubs`` and ``--saplings`` options allow normal plants
56+
to be targeted instead. Removal of fully-grown trees isn't currently supported.
57+
58+
Examples
59+
--------
60+
61+
``plant list``
62+
List all valid shrub and sapling raw IDs.
63+
``plant create tower_cap``
64+
Create a Tower Cap sapling at the cursor.
65+
``plant create 203 -c -a tree``
66+
Create a Willow sapling at the cursor, even away from water features,
67+
ready to mature into a tree.
68+
``plant create single-grain_wheat 70,70,140``
69+
Create a Single-grain Wheat shrub at (70, 70, 140).
70+
``plant grow``
71+
Attempt to grow all saplings on the map into trees.
72+
``plant grow -z -f maple,200,sand_pear``
73+
Attempt to grow all Maple, Acacia, and Sand Pear saplings on the current
74+
z-level into trees.
75+
``plant grow 0,0,100 19,19,119 -a 10``
76+
Set the age of all saplings and trees (with their original sapling tile)
77+
in the defined 20 x 20 x 20 cube to at least 10 years.
78+
``plant remove``
79+
Remove all invalid plants from the map.
80+
``plant remove here -sp``
81+
Remove the shrub or sapling at the cursor.
82+
``plant remove -spd``
83+
Remove all dead shrubs and saplings from the map.
84+
``plant remove 0,0,49 0,0,51 -pz -e nether_cap``
85+
Remove all saplings on z-levels 49 to 51, excluding Nether Cap.
86+
87+
Create Options
88+
--------------
89+
90+
``-c``, ``--force``
91+
Create plant even on tiles flagged ``no_grow`` and unset the flag. This
92+
flag is set on tiles that were originally boulders or pebbles, as well
93+
as on some tiles found in deserts, etc. Also allow non-``[DRY]`` plants
94+
(e.g., willow) to grow away (3+ tiles) from water features (i.e., pools,
95+
brooks, and rivers), and non-``[WET]`` plants (e.g., prickle berry) to
96+
grow near them.
97+
``-a``, ``--age <value>``
98+
Set the created plant to a specific age (in years). ``value`` can be a
99+
non-negative integer, or one of the strings ``tree``/``1x1`` (3 years),
100+
``2x2`` (201 years), or ``3x3`` (401 years). ``value`` will be capped at
101+
1250. Defaults to 0 if option is unused. Only a few tree types grow wider
102+
than 1x1, but many may grow taller. (Going directly to higher years will
103+
stunt height. It may be more desirable to instead use ``plant grow`` in
104+
stages, or just spawn full trees using `gui/sandbox`.)
105+
106+
Grow Options
107+
------------
108+
109+
``-a``, ``--age <value>``
110+
Define the age (in years) to set saplings to. ``value`` can be a
111+
non-negative integer, or one of the strings ``tree``/``1x1`` (3 years),
112+
``2x2`` (201 years), or ``3x3`` (401 years). ``value`` will be capped at
113+
1250. Defaults to 3 if option is unused. If a ``value`` larger than 3 is
114+
used, it will make sure even fully-grown trees have an age of at least the
115+
given value, allowing them to grow larger. (Going directly to higher years
116+
will stunt tree height. It may be more desirable to grow in stages rather
117+
than all at once. Trees grow taller every 10 years.)
118+
``-f``, ``--filter <plant_id>[,<plant_id>...]``
119+
Define a filter list of plant raw IDs to target, ignoring all other tree
120+
types. ``plant_id`` is not case-sensitive, but must be enclosed in quotes
121+
if spaces exist. (No unmodded tree raw IDs have spaces.) A numerical ID
122+
can be used in place of a string. Use ``plant list`` and check under
123+
``Saplings`` for a list of valid IDs.
124+
``-e``, ``--exclude <plant_id>[,<plant_id>...]``
125+
Same as ``--filter``, but target everything except these. Cannot be used
126+
with ``--filter``.
127+
``-z``, ``--zlevel``
128+
Operate on a range of z-levels instead of default targeting. Will do all
129+
z-levels between ``pos`` arguments if both are given (instead of cuboid),
130+
z-level of first ``pos`` if one is given (instead of single tile), else
131+
z-level of current view if no ``pos`` is given (instead of entire map).
132+
``-n``, ``--dry-run``
133+
Don't actually grow plants. Just print the total number of plants that
134+
would be grown.
135+
136+
Remove Options
137+
--------------
138+
139+
``-s``, ``--shrubs``
140+
Target shrubs for removal.
141+
``-p``, ``--saplings``
142+
Target saplings for removal.
143+
``-d``, ``--dead``
144+
Only target dead plants for removal. Can't be used without ``--shrubs``
145+
or ``--saplings``.
146+
``-f``, ``--filter <plant_id>[,<plant_id>...]``
147+
Define a filter list of plant raw IDs to target, ignoring all other plant
148+
types. This applies after ``--shrubs`` and ``--saplings`` are targeted,
149+
and can't be used without one of those options. ``plant_id`` is not
150+
case-sensitive, but must be enclosed in quotes if spaces exist. (No
151+
unmodded shrub or sapling raw IDs have spaces.) A numerical ID can be
152+
used in place of a string. Use ``plant list`` for a list of valid IDs.
153+
``-e``, ``--exclude <plant_id>[,<plant_id>...]``
154+
Same as ``--filter``, but target everything except these. Cannot be used
155+
with ``--filter``.
156+
``-z``, ``--zlevel``
157+
Operate on a range of z-levels instead of default targeting. Will do all
158+
z-levels between ``pos`` arguments if both are given (instead of cuboid),
159+
z-level of first ``pos`` if one is given (instead of single tile), else
160+
z-level of current view if no ``pos`` is given (instead of entire map).
161+
``-n``, ``--dryrun``
162+
Don't actually remove plants. Just print the total number of plants that
163+
would be removed.

docs/plugins/plants.rst

Lines changed: 0 additions & 33 deletions
This file was deleted.

docs/plugins/regrass.rst

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ regrass
33

44
.. dfhack-tool::
55
:summary: Regrow surface grass and cavern moss.
6-
:tags: adventure fort armok animals map
6+
:tags: adventure fort armok animals map plants
77

88
This command can refresh the grass (and subterranean moss) growing on your map.
99
Operates on floors, stairs, and ramps. Also works underneath shrubs, saplings,
@@ -24,9 +24,45 @@ can be used in place of numeric coordinates to use the position of the keyboard
2424
cursor, if active. The ``--block`` and ``--zlevel`` options use the ``pos``
2525
values differently.
2626

27+
Examples
28+
--------
29+
30+
``regrass``
31+
Regrass the entire map, refilling existing and depleted grass.
32+
``regrass here``
33+
Regrass the selected tile, refilling existing and depleted grass.
34+
``regrass here 0,0,90 --zlevel``
35+
Regrass all z-levels including the selected tile's z-level through z-level
36+
90, refilling existing and depleted grass.
37+
``regrass 0,0,100 19,19,119 --ashes --mud``
38+
Regrass tiles in the 20 x 20 x 20 cube defined by the coords, refilling
39+
existing and depleted grass, and converting ashes and muddy stone (if
40+
respective blocks ever had grass).
41+
``regrass 10,10,100 -baudnm``
42+
Regrass the block that contains the given coord; converting ashes, muddy
43+
stone, and tiles under buildings; adding all compatible grass types, and
44+
filling each grass type to max.
45+
``regrass -f``
46+
Regrass the entire map, refilling existing and depleted grass, else filling
47+
with a randomly selected grass type if non-existent.
48+
``regrass -l``
49+
Print all valid grass raw IDs for use with ``--plant``. Both numerical and
50+
string IDs are provided. This ignores all other options and skips regrass.
51+
``regrass -zf -p 128``
52+
Regrass the current z-level, refilling existing and depleted grass, else
53+
filling with ``underlichen`` if non-existent.
54+
``regrass here -bnf -p "dog's tooth grass"``
55+
Regrass the selected block, adding all compatible grass types to block data,
56+
``dog's tooth grass`` if no compatible types exist. Refill existing grass
57+
on each tile, else select one of the block's types if depleted or
58+
previously non-existent.
59+
2760
Options
2861
-------
2962

63+
``-l``, ``--list``
64+
List all available grass raw IDs that you can later pass to the ``--plant``
65+
option. The map will not be affected when running with this option.
3066
``-m``, ``--max``
3167
Maxes out every grass type in the tile, giving extra grazing time.
3268
Not normal DF behavior. Tile will appear to be the first type of grass
@@ -44,12 +80,13 @@ Options
4480
forced instead. By default, a single random grass type is selected from
4581
the world's raws. The ``--plant`` option allows a specific grass type to be
4682
specified.
47-
``-p <grass_id>``, ``--plant <grass_id>``
83+
``-p``, ``--plant <grass_id>``
4884
Specify a grass type for the ``--force`` option. ``grass_id`` is not
49-
case-sensitive, but must be enclosed in quotes if spaces exist. Providing
50-
an empty string with "" will print all available IDs and skip regrass.
85+
case-sensitive, but must be enclosed in quotes if spaces exist. A numerical
86+
ID can also be used.
5187
``-a``, ``--ashes``
52-
Regrass tiles that've been burnt to ash.
88+
Regrass tiles that've been burnt to ash. Usually ash must revert to soil
89+
first before grass can grow.
5390
``-d``, ``--buildings``
5491
Regrass tiles under certain passable building tiles including stockpiles,
5592
planned buildings, workshops, and farms. (Farms will convert grass tiles to
@@ -65,40 +102,8 @@ Options
65102
`devel/block-borders` can be used to visualize map blocks.
66103
``-z``, ``--zlevel``
67104
Regrass entire z-levels. Will do all z-levels between ``pos`` arguments if
68-
both given, z-level of first ``pos`` if one given, else z-level of
69-
viewscreen if no ``pos`` given.
70-
71-
Examples
72-
--------
73-
74-
``regrass``
75-
Regrass the entire map, refilling existing and depleted grass.
76-
``regrass here``
77-
Regrass the selected tile, refilling existing and depleted grass.
78-
``regrass here 0,0,90 --zlevel``
79-
Regrass all z-levels including the selected tile's z-level through z-level
80-
90, refilling existing and depleted grass.
81-
``regrass 0,0,100 19,19,119 --ashes --mud``
82-
Regrass tiles in the 20x20x20 cube defined by the coords, refilling
83-
existing and depleted grass, and converting ashes and muddy stone (if
84-
respective blocks ever had grass.)
85-
``regrass 10,10,100 -baudnm``
86-
Regrass the block that contains the given coord; converting ashes, muddy
87-
stone, and tiles under buildings; adding all compatible grass types, and
88-
filling each grass type to max.
89-
``regrass -f``
90-
Regrass the entire map, refilling existing and depleted grass, else filling
91-
with a randomly selected grass type if non-existent.
92-
``regrass -p ""``
93-
Print all valid grass raw ids. Don't regrass.
94-
``regrass -zf -p underlichen``
95-
Regrass the current z-level, refilling existing and depleted grass, else
96-
filling with ``underlichen`` if non-existent.
97-
``regrass here -bnf -p "dog's tooth grass"``
98-
Regrass the selected block, adding all compatible grass types to block data,
99-
``dog's tooth grass`` if no compatible types exist. Refill existing grass
100-
on each tile, else select one of the block's types if depleted or
101-
previously non-existent.
105+
both are given, z-level of first ``pos`` if one is given, else z-level of
106+
current view if no ``pos`` is given.
102107

103108
Troubleshooting
104109
---------------

plugins/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ if(BUILD_SUPPORTED)
141141
dfhack_plugin(overlay overlay.cpp LINK_LIBRARIES lua)
142142
dfhack_plugin(pathable pathable.cpp LINK_LIBRARIES lua)
143143
dfhack_plugin(pet-uncapper pet-uncapper.cpp)
144-
#dfhack_plugin(plants plants.cpp)
144+
dfhack_plugin(plant plant.cpp LINK_LIBRARIES lua)
145145
dfhack_plugin(preserve-tombs preserve-tombs.cpp)
146146
dfhack_plugin(probe probe.cpp LINK_LIBRARIES lua)
147147
dfhack_plugin(prospector prospector.cpp LINK_LIBRARIES lua)

0 commit comments

Comments
 (0)