forked from DFHack/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
forget-dead-body.lua
53 lines (43 loc) · 1.11 KB
/
forget-dead-body.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
-- Removes emotions associated with seeing a dead body
--@ module = true
local help = [====[
forget-dead-body
================
Removes emotions associated with seeing a dead body.
]====]
local utils = require 'utils'
local validArgs = utils.invert({
'help',
'all',
})
function forgetDeadBody(unit)
for _, t in ipairs(unit.status.current_soul.personality.emotions) do
if t.thought == df.unit_thought_type.SawDeadBody then
t.type = df.emotion_type.ANYTHING
end
end
end
function main(...)
local args = utils.processArgs({...}, validArgs)
if args.help then
print(help)
return
end
if args.all then
for _, unit in ipairs(df.global.world.units.active) do
if dfhack.units.isCitizen(unit) then
forgetDeadBody(unit)
end
end
else
local unit = dfhack.gui.getSelectedUnit()
if unit then
forgetDeadBody(unit)
else
qerror('Invalid usage: No unit selected and -all argument not given.')
end
end
end
if not dfhack_flags.module then
main(...)
end