From b74a2930dfc80d21295101d1c8a3d3a5fb2eb428 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 6 Oct 2023 16:12:50 -0700 Subject: [PATCH] clean up remove-wear code --- remove-wear.lua | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/remove-wear.lua b/remove-wear.lua index 58406a1b6d..90621b54c9 100644 --- a/remove-wear.lua +++ b/remove-wear.lua @@ -1,33 +1,21 @@ -- Reset items in your fort to 0 wear -- original author: Laggy, edited by expwnent -local help = [====[ - -remove-wear -=========== -Sets the wear on items in your fort to zero. Usage: - -:remove-wear all: - Removes wear from all items in your fort. -:remove-wear ID1 ID2 ...: - Removes wear from items with the given ID numbers. - -]====] local args = {...} local count = 0 -if args[1] == 'help' then - print(help) +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.all) do - if item.wear > 0 then --hint:df.item_actual + if item:getWear() > 0 then --hint:df.item_actual item:setWear(0) count = count + 1 end end else - for i, arg in ipairs(args) do + for _, arg in ipairs(args) do local item_id = tonumber(arg) if item_id then local item = df.item.find(item_id) @@ -43,4 +31,4 @@ else end end -print('remove-wear: removed wear from '..count..' objects') +print('remove-wear: removed wear from '..tostring(count)..' items')