From 7a20d0eb990d9488b25d1df450802d42a9369a18 Mon Sep 17 00:00:00 2001 From: Quinn Cypher Date: Tue, 10 Oct 2023 02:05:46 -0400 Subject: [PATCH 1/7] Initial update + docs --- burial.lua | 51 ++++++++++++++++++++++++++++--------------------- docs/burial.rst | 22 ++++++++++++--------- 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/burial.lua b/burial.lua index 3f75c50b46..144b1a2136 100644 --- a/burial.lua +++ b/burial.lua @@ -1,27 +1,34 @@ --- allows burial in unowned coffins --- by Putnam https://gist.github.com/Putnam3145/e7031588f4d9b24b9dda ---[====[ +-- Allows burial in unowned coffins. +-- Based on Putnam's work (https://gist.github.com/Putnam3145/e7031588f4d9b24b9dda) +local argparse = require('argparse') +local utils = require('utils') -burial -====== -Sets all unowned coffins to allow burial. ``burial -pets`` also allows burial -of pets. +local args = argparse.processArgs({...}, utils.invert{'d', 'p'}) -]====] - -local utils=require('utils') - -local validArgs = utils.invert({ - 'pets' -}) - -local args = utils.processArgs({...}, validArgs) - -for k,v in ipairs(df.global.world.buildings.other.COFFIN) do --as:df.building_coffinst - if v.owner_id==-1 then - v.burial_mode.allow_burial=true - if not args.pets then - v.burial_mode.no_pets=true +for i, c in pairs(df.global.world.buildings.other.COFFIN) do + -- Check for existing tomb + for i, z in pairs(c.relations) do + if z.type == df.civzone_type.Tomb then + goto skip end end + + dfhack.buildings.constructBuilding { + type = df.building_type.Civzone, + subtype = df.civzone_type.Tomb, + pos = xyz2pos(c.x1, c.y1, c.z), + abstract = true, + fields = { + is_active = 8, + zone_settings = { + tomb = { + no_pets = args.d and not args.p, + no_citizens = args.p and not args.d, + }, + }, + }, + } + + ::skip:: end + diff --git a/docs/burial.rst b/docs/burial.rst index 19e58b9b87..db7601e526 100644 --- a/docs/burial.rst +++ b/docs/burial.rst @@ -2,20 +2,24 @@ burial ====== .. dfhack-tool:: - :summary: Configures all unowned coffins to allow burial. - :tags: unavailable fort productivity buildings + :summary: Allows burial in unowned coffins. + :tags: fort productivity buildings + +Creates a 1x1 tomb zone for each built coffin that doesn't already have one. Usage ----- -:: + ``burial [-d] [-p]`` - burial [--pets] +Created tombs allow both dwarves and pets by default. By specifying ``-d`` or +``-p``, they can be restricted to dwarves or pets, respectively. -if the ``--pets`` option is passed, coffins will also allow burial of pets. +Options +------- -Examples --------- +``-d`` + Create dwarf-only tombs +``-p`` + Create pet-only tombs -``burial --pets`` - Configures all unowned coffins to allow burial, including pets. From 6b5e442fd17c28738020de309cbc24533784161f Mon Sep 17 00:00:00 2001 From: Quinn Cypher Date: Tue, 10 Oct 2023 02:23:43 -0400 Subject: [PATCH 2/7] Added burial update to changelog --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index d03ae453cc..798530521d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -28,6 +28,7 @@ Template for new versions: ## New Tools - `add-recipe`: (reinstated) add reactions to your civ (e.g. for high boots if your civ didn't start with the ability to make high boots) +- `burial`: (reinstated) allows burial in unowned coffins (now creates tomb zones for all built coffins) ## New Features - `drain-aquifer`: gained ability to drain just above or below a certain z-level From 0b1dbac90d84554f6854927baef8e6dd32341dd5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:21:50 +0000 Subject: [PATCH 3/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- burial.lua | 3 +-- docs/burial.rst | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/burial.lua b/burial.lua index 144b1a2136..2b49f9a1ab 100644 --- a/burial.lua +++ b/burial.lua @@ -12,7 +12,7 @@ for i, c in pairs(df.global.world.buildings.other.COFFIN) do goto skip end end - + dfhack.buildings.constructBuilding { type = df.building_type.Civzone, subtype = df.civzone_type.Tomb, @@ -31,4 +31,3 @@ for i, c in pairs(df.global.world.buildings.other.COFFIN) do ::skip:: end - diff --git a/docs/burial.rst b/docs/burial.rst index db7601e526..befd16ba1a 100644 --- a/docs/burial.rst +++ b/docs/burial.rst @@ -22,4 +22,3 @@ Options Create dwarf-only tombs ``-p`` Create pet-only tombs - From 218cae668a6762cb59fc571e528e9a3484dbbae8 Mon Sep 17 00:00:00 2001 From: Quinn Cypher Date: Thu, 12 Oct 2023 14:43:02 -0400 Subject: [PATCH 4/7] Now using quickfort, added zlevel option --- burial.lua | 47 ++++++++++++++++++++++++++--------------------- docs/burial.rst | 38 +++++++++++++++++++++++++++++--------- 2 files changed, 55 insertions(+), 30 deletions(-) diff --git a/burial.lua b/burial.lua index 2b49f9a1ab..ea1924c422 100644 --- a/burial.lua +++ b/burial.lua @@ -1,33 +1,38 @@ -- Allows burial in unowned coffins. -- Based on Putnam's work (https://gist.github.com/Putnam3145/e7031588f4d9b24b9dda) local argparse = require('argparse') -local utils = require('utils') +local quickfort = reqscript('quickfort') -local args = argparse.processArgs({...}, utils.invert{'d', 'p'}) +local cur_zlevel, citizens, pets = false, true, true +argparse.processArgsGetopt({...}, { + {'z', 'cur-zlevel', handler=function() cur_zlevel = true end}, + {'c', 'citizens-only', handler=function() pets = false end}, + {'p', 'pets-only', handler=function() citizens = false end}, +}) +local tomb_blueprint = { + mode = 'zone', + pos = nil, + -- Don't pass properties with default values to avoid 'unhandled property' warning + data = ('T{%s %s}'):format(citizens and '' or 'citizens=false', pets and 'pets=true' or ''), +} -for i, c in pairs(df.global.world.buildings.other.COFFIN) do - -- Check for existing tomb - for i, z in pairs(c.relations) do - if z.type == df.civzone_type.Tomb then +local tomb_count = 0 +for _, coffin in pairs(df.global.world.buildings.other.COFFIN) do + + if cur_zlevel and not (coffin.z == df.global.window_z) then + goto skip + end + for _, zone in pairs(coffin.relations) do + if zone.type == df.civzone_type.Tomb then goto skip end end - dfhack.buildings.constructBuilding { - type = df.building_type.Civzone, - subtype = df.civzone_type.Tomb, - pos = xyz2pos(c.x1, c.y1, c.z), - abstract = true, - fields = { - is_active = 8, - zone_settings = { - tomb = { - no_pets = args.d and not args.p, - no_citizens = args.p and not args.d, - }, - }, - }, - } + tomb_blueprint.pos = xyz2pos(coffin.x1, coffin.y1, coffin.z) + quickfort.apply_blueprint(tomb_blueprint) + tomb_count = tomb_count + 1 ::skip:: end + +print(('Created %s tombs.'):format(tomb_count)) diff --git a/docs/burial.rst b/docs/burial.rst index befd16ba1a..abc85b6264 100644 --- a/docs/burial.rst +++ b/docs/burial.rst @@ -3,22 +3,42 @@ burial .. dfhack-tool:: :summary: Allows burial in unowned coffins. - :tags: fort productivity buildings + :tags: fort | productivity | buildings -Creates a 1x1 tomb zone for each built coffin that doesn't already have one. +Creates a 1x1 tomb zone for each built coffin that isn't already in a tomb. Usage ----- - ``burial [-d] [-p]`` + ``burial []`` -Created tombs allow both dwarves and pets by default. By specifying ``-d`` or -``-p``, they can be restricted to dwarves or pets, respectively. +Examples +-------- + +``burial`` + Create a tomb for every coffin on the map with automatic burial enabled. + +``burial -z`` + Create tombs only on the current zlevel. + +``burial -c`` + Create tombs designated for automatic burial of citizens only. + +``burial -p`` + Create tombs designated for automatic burial of pets only. + +``burial -cp`` + Create tombs with automatic burial disabled for both citizens and pets, + requiring manual assignment of deceased units to each tomb. Options ------- -``-d`` - Create dwarf-only tombs -``-p`` - Create pet-only tombs +``-z``, ``--cur-zlevel`` + Only create tombs on the current zlevel. + +``-c``, ``--citizens-only`` + Only automatically bury citizens. + +``-p``, ``--pets-only`` + Only automatically bury pets. From 3d4854e1b21b60ad8b0957f6de7cc27fbdbd12ee Mon Sep 17 00:00:00 2001 From: Quinn Cypher Date: Fri, 13 Oct 2023 11:21:52 -0400 Subject: [PATCH 5/7] Apply suggestions from code review Co-authored-by: Myk --- burial.lua | 2 +- docs/burial.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/burial.lua b/burial.lua index ea1924c422..caf01e0064 100644 --- a/burial.lua +++ b/burial.lua @@ -35,4 +35,4 @@ for _, coffin in pairs(df.global.world.buildings.other.COFFIN) do ::skip:: end -print(('Created %s tombs.'):format(tomb_count)) +print(('Created %s tomb(s).'):format(tomb_count)) diff --git a/docs/burial.rst b/docs/burial.rst index abc85b6264..506d1a8715 100644 --- a/docs/burial.rst +++ b/docs/burial.rst @@ -2,8 +2,8 @@ burial ====== .. dfhack-tool:: - :summary: Allows burial in unowned coffins. - :tags: fort | productivity | buildings + :summary: Create tomb zones for unzoned coffins. + :tags: fort productivity buildings Creates a 1x1 tomb zone for each built coffin that isn't already in a tomb. From 923f10d98d69efc2a59fcadab591d4bdf71e0031 Mon Sep 17 00:00:00 2001 From: Quinn Cypher Date: Fri, 13 Oct 2023 12:00:53 -0400 Subject: [PATCH 6/7] New burial options --- changelog.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 798530521d..398cfb8747 100644 --- a/changelog.txt +++ b/changelog.txt @@ -28,9 +28,10 @@ Template for new versions: ## New Tools - `add-recipe`: (reinstated) add reactions to your civ (e.g. for high boots if your civ didn't start with the ability to make high boots) -- `burial`: (reinstated) allows burial in unowned coffins (now creates tomb zones for all built coffins) +- `burial`: (reinstated) create tomb zones for unzoned coffins ## New Features +- `burial`: new options to configure automatic burial and limit scope to the current z-level - `drain-aquifer`: gained ability to drain just above or below a certain z-level - `drain-aquifer`: new option to drain all layers except for the first N aquifer layers, in case you want some aquifer layers but not too many - `gui/control-panel`: ``drain-aquifer --top 2`` added as an autostart option From 22238c9707be9335dd18e92505dcf393d6267baa Mon Sep 17 00:00:00 2001 From: Myk Date: Sat, 14 Oct 2023 12:28:50 -0700 Subject: [PATCH 7/7] Update burial.lua --- burial.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/burial.lua b/burial.lua index caf01e0064..3bc7f1072c 100644 --- a/burial.lua +++ b/burial.lua @@ -19,7 +19,7 @@ local tomb_blueprint = { local tomb_count = 0 for _, coffin in pairs(df.global.world.buildings.other.COFFIN) do - if cur_zlevel and not (coffin.z == df.global.window_z) then + if cur_zlevel and coffin.z ~= df.global.window_z then goto skip end for _, zone in pairs(coffin.relations) do