2014-06-26 06:36:57 -06:00
|
|
|
-- Resets all items in your fort to 0 wear
|
2015-11-09 19:52:20 -07:00
|
|
|
-- original author: Laggy, edited by expwnent
|
2015-10-23 22:10:15 -06:00
|
|
|
--[[=begin
|
|
|
|
|
|
|
|
remove-wear
|
|
|
|
===========
|
|
|
|
Sets the wear on all items in your fort to zero.
|
|
|
|
|
|
|
|
=end]]
|
2014-06-26 06:36:57 -06:00
|
|
|
|
|
|
|
local args = {...}
|
|
|
|
|
|
|
|
if args[1] == 'help' then
|
2014-07-09 04:21:52 -06:00
|
|
|
print([[remove-wear - this script removes wear from all items, or from individual ones
|
2014-06-26 06:36:57 -06:00
|
|
|
|
2014-07-09 04:21:52 -06:00
|
|
|
remove-wear all
|
2014-06-26 06:36:57 -06:00
|
|
|
remove wear from all items
|
2014-07-09 04:21:52 -06:00
|
|
|
remove-wear n1 n2 n3 ...
|
2014-06-26 06:36:57 -06:00
|
|
|
remove wear from items with the given ids. order does not matter
|
2014-07-09 04:21:52 -06:00
|
|
|
repeat -time 2 months -command remove-wear all
|
2014-06-26 06:36:57 -06:00
|
|
|
remove wear from all items every 2 months. see repeat.lua for details
|
|
|
|
]])
|
|
|
|
do return end
|
|
|
|
elseif args[1] == 'all' then
|
|
|
|
local count = 0;
|
|
|
|
for _,item in ipairs(df.global.world.items.all) do
|
|
|
|
if (item.wear > 0) then
|
|
|
|
item:setWear(0)
|
|
|
|
count = count+1
|
|
|
|
end
|
|
|
|
end
|
2014-07-09 04:21:52 -06:00
|
|
|
print('remove-wear removed wear from '..count..' objects')
|
2014-06-26 06:36:57 -06:00
|
|
|
else
|
|
|
|
local argIndex = 1
|
|
|
|
local isCompleted = {}
|
|
|
|
for i,x in ipairs(args) do
|
|
|
|
args[i] = tonumber(x)
|
|
|
|
end
|
|
|
|
table.sort(args)
|
|
|
|
for _,item in ipairs(df.global.world.items.all) do
|
|
|
|
local function loop()
|
|
|
|
if argIndex > #args then
|
|
|
|
return
|
|
|
|
elseif item.id > args[argIndex] then
|
|
|
|
argIndex = argIndex+1
|
|
|
|
loop()
|
|
|
|
return
|
|
|
|
elseif item.id == args[argIndex] then
|
|
|
|
--print('removing wear from item with id ' .. args[argIndex])
|
|
|
|
item:setWear(0)
|
|
|
|
isCompleted[args[argIndex]] = true
|
|
|
|
argIndex = argIndex+1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
loop()
|
|
|
|
end
|
|
|
|
for _,arg in ipairs(args) do
|
|
|
|
if isCompleted[arg] ~= true then
|
|
|
|
print('failed to remove wear from item ' .. arg .. ': could not find item with that id')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|