Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 232
Expand file tree
/
Copy pathjustice.lua
More file actions
Latest commit
61 lines (53 loc) · 1.75 KB
/
Copy pathjustice.lua
File metadata and controls
61 lines (53 loc) · 1.75 KB
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
54
55
56
57
58
59
60
61
localargparse=require('argparse')
localTICKS_PER_SEASON_TICK=10
localTICKS_PER_DAY=1200
localfunctionlist_convicts()
localfound=false
for_,punishmentinipairs(df.global.plotinfo.punishments) do
localunit=df.unit.find(punishment.criminal)
ifunitandpunishment.prison_counter>0then
found=true
localdays=math.ceil((punishment.prison_counter*TICKS_PER_SEASON_TICK) /TICKS_PER_DAY)
print(('%s (id: %d): serving a sentence of %d day(s)'):format(
dfhack.units.getReadableName(unit), unit.id, days))
end
end
ifnotfoundthen
print('No criminals currently serving sentences.')
end
end
localfunctionpardon_unit(unit)
for_,punishmentinipairs(df.global.plotinfo.punishments) do
ifpunishment.criminal==unit.idthen
punishment.prison_counter=0
return
end
end
qerror('Unit is not currently serving a sentence!')
end
localfunctioncommand_pardon(unit_id)
localunit=nil
ifnotunit_idthen
unit=dfhack.gui.getSelectedUnit(true)
ifnotunitthenqerror('No unit selected!') end
else
unit=df.unit.find(unit_id)
ifnotunitthenqerror(('No unit with id %d'):format(unit_id)) end
end
pardon_unit(unit)
end
localunit_id=nil
localpositionals=argparse.processArgsGetopt({...},
{
{'u', 'unit', hasArg=true,
handler=function(optarg) unit_id=argparse.nonnegativeInt(optarg, 'unit') end},
}
)
localcommand=positionals[1]
ifcommand=='pardon' then
command_pardon(unit_id)
elseifnotcommandorcommand=='list' then
list_convicts()
else
qerror(('Unrecognised command: %s'):format(command))
end