-
Notifications
You must be signed in to change notification settings - Fork 199
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
Burial update #859
Merged
Merged
Burial update #859
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7a20d0e
Initial update + docs
tmqCypher 6b5e442
Added burial update to changelog
tmqCypher 0b1dbac
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 218cae6
Now using quickfort, added zlevel option
tmqCypher 3d4854e
Apply suggestions from code review
tmqCypher 923f10d
New burial options
tmqCypher 22238c9
Update burial.lua
myk002 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
-- 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 quickfort = reqscript('quickfort') | ||
|
||
burial | ||
====== | ||
Sets all unowned coffins to allow burial. ``burial -pets`` also allows burial | ||
of pets. | ||
|
||
]====] | ||
|
||
local utils=require('utils') | ||
|
||
local validArgs = utils.invert({ | ||
'pets' | ||
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 ''), | ||
} | ||
|
||
local args = utils.processArgs({...}, validArgs) | ||
local tomb_count = 0 | ||
for _, coffin in pairs(df.global.world.buildings.other.COFFIN) do | ||
|
||
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 | ||
if cur_zlevel and 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 | ||
|
||
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 tomb(s).'):format(tomb_count)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice. I like that you documented this use case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Two options logically excluding each other probably isn't the most semantically straightforward way to access a feature, but it puts the docs to good use