move all chatcommands to the same place

This commit is contained in:
FaceDeer 2020-01-10 11:00:36 -07:00
parent db0d0f99db
commit 5cede8dd9b
2 changed files with 27 additions and 30 deletions

View File

@ -8,33 +8,3 @@ dofile(MP.."/doc.lua")
dofile(MP.."/default_markets.lua")
dofile(MP.."/mapgen_dungeon_markets.lua")
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
minetest.register_chatcommand("market.show", {
params = "marketname",
privs = {server=true},
description = S("show market formspec"),
func = function(name, param)
local market = commoditymarket.registered_markets[param]
if market == nil then return end
local formspec = market:get_formspec(market:get_account(name))
minetest.show_formspec(name, "commoditymarket:"..param..":"..name, formspec)
end,
})
minetest.register_chatcommand("market.list", {
params = "",
privs = {server=true},
description = S("list all registered markets"),
func = function(name, param)
local list = {}
for marketname, def in pairs(commoditymarket.registered_markets) do
table.insert(list, marketname)
end
table.sort(list)
minetest.chat_send_player(name, "Registered markets: " .. table.concat(list, ", "))
end,
})

View File

@ -377,6 +377,33 @@ local initialize_market_item = function(orders_for_items, item)
end
-----------------------------------------------------------------------------------------------------------
-- Chat commands
minetest.register_chatcommand("market.show", {
params = "marketname",
privs = {server=true},
description = S("show market formspec"),
func = function(name, param)
local market = commoditymarket.registered_markets[param]
if market == nil then return end
local formspec = market:get_formspec(market:get_account(name))
minetest.show_formspec(name, "commoditymarket:"..param..":"..name, formspec)
end,
})
minetest.register_chatcommand("market.list", {
params = "",
privs = {server=true},
description = S("list all registered markets"),
func = function(name, param)
local list = {}
for marketname, def in pairs(commoditymarket.registered_markets) do
table.insert(list, marketname)
end
table.sort(list)
minetest.chat_send_player(name, "Registered markets: " .. table.concat(list, ", "))
end,
})
local remove_market_item = function(market, item)
local marketitem = market.orders_for_items[item]