add a command to purge all unknown items from all markets

This commit is contained in:
FaceDeer 2019-08-05 00:39:36 -06:00
parent 716513002c
commit 14edd9b4d8

View File

@ -125,7 +125,7 @@ end
------------------------------------------------------------------------------------------
local add_inventory_to_account = function(market, account, item, quantity)
if quantity < 1 or minetest.registered_items[item] == nil then
if quantity < 1 then
return false
end
@ -367,6 +367,26 @@ minetest.register_chatcommand("market.removeitem", {
end,
})
minetest.register_chatcommand("market.purge_unknowns", {
params = "",
privs = {server=true},
decription = "removes all unknown items from all markets. All existing buys and sells for those items will be cancelled.",
func = function(name, param)
for market_name, market in pairs(commoditymarket.registered_markets) do
local items_to_remove = {}
local items_to_move = {}
for item, orders in pairs(market.orders_for_items) do
if minetest.registered_items[item] == nil then
table.insert(items_to_remove, item)
end
end
for _, item in ipairs(items_to_remove) do
remove_market_item(market, item)
end
end
end,
})
-----------------------------------------------------------------------------------------------------------
local initialize_market_item = function(orders_for_items, item)