-
Notifications
You must be signed in to change notification settings - Fork 199
/
remove-wear.lua
34 lines (31 loc) · 1004 Bytes
/
remove-wear.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
-- Reset items in your fort to 0 wear
-- original author: Laggy, edited by expwnent
local args = {...}
local count = 0
if not args[1] or args[1] == 'help' or args[1] == '-h' or args[1] == '--help' then
print(dfhack.script_help())
return
elseif args[1] == 'all' or args[1] == '-all' then
for _, item in ipairs(df.global.world.items.other.IN_PLAY) do
if item:getWear() > 0 then --hint:df.item_actual
item:setWear(0)
count = count + 1
end
end
else
for _, arg in ipairs(args) do
local item_id = tonumber(arg)
if item_id then
local item = df.item.find(item_id)
if item then
item:setWear(0)
count = count + 1
else
dfhack.printerr('remove-wear: could not find item: ' .. item_id)
end
else
qerror('Invalid item ID: ' .. arg)
end
end
end
print('remove-wear: removed wear from '..tostring(count)..' items')