fix bug with unknown item market listing display
This commit is contained in:
parent
ff77efa4cc
commit
17d88415d0
@ -258,8 +258,8 @@ local get_market_formspec = function(market, account)
|
||||
formspec[#formspec+1] = "," .. item_display
|
||||
end
|
||||
|
||||
local def = minetest.registered_items[row.item] or {}
|
||||
local desc_display = def.description:gsub("\n", " ") or "Unknown Item"
|
||||
local def = minetest.registered_items[row.item] or {description = "Unknown Item"}
|
||||
local desc_display = def.description:gsub("\n", " ")
|
||||
if desc_display:len() > truncate_length then
|
||||
desc_display = desc_display:sub(1,truncate_length-2).."..."
|
||||
end
|
||||
@ -304,8 +304,8 @@ local get_market_formspec = function(market, account)
|
||||
if show_itemnames then
|
||||
desc_display = selected
|
||||
else
|
||||
local def = minetest.registered_items[selected_row.item] or {}
|
||||
desc_display = def.description:gsub("\n", " ") or "Unknown Item"
|
||||
local def = minetest.registered_items[selected_row.item] or {description="Unknown Item"}
|
||||
desc_display = def.description:gsub("\n", " ")
|
||||
end
|
||||
|
||||
-- player inventory for this item and for currency
|
||||
@ -370,6 +370,7 @@ local get_market_formspec = function(market, account)
|
||||
else
|
||||
formspec[#formspec+1] = "label[0.1,5.1;Select an item to view or place orders]"
|
||||
end
|
||||
minetest.debug(table.concat(formspec))
|
||||
return table.concat(formspec)
|
||||
end
|
||||
|
||||
|
@ -419,7 +419,7 @@ end
|
||||
commoditymarket.register_market = function(market_name, market_def)
|
||||
assert(not commoditymarket.registered_markets[market_name])
|
||||
|
||||
market_def.currency_symbol = market_def.currency_symbol or "\u{00A4}" -- defaults to the generic currency symbol ("scarab")
|
||||
market_def.currency_symbol = market_def.currency_symbol or "¤" -- \u{00A4} -- defaults to the generic currency symbol ("scarab")
|
||||
market_def.description = market_def.description or "Market"
|
||||
market_def.long_description = market_def.long_description or "A market where orders to buy or sell items can be placed and fulfilled."
|
||||
|
||||
|
25
readme.md
25
readme.md
@ -67,4 +67,27 @@ The file "default_markets.lua" contains a number of pre-defined markets that pro
|
||||
* Goblin Exchange - a strange marketplace that uses coal as a currency
|
||||
* Undermarket - where dark powers make their trades, using Mese as a currency
|
||||
|
||||
All of these except for the Trader's Caravan are intended to be placed in specific locations by server administrators, they have on_dig methods that prevent them from being removed and don't have crafting recipes. Modifying these markets or creating your own from scratch should hopefully be a fairly straightforward task, however.
|
||||
All of these except for the Trader's Caravan are intended to be placed in specific locations by server administrators, they don't have crafting recipes. Modifying these markets or creating your own from scratch should hopefully be a fairly straightforward task.
|
||||
|
||||
### Market definition API
|
||||
|
||||
```
|
||||
local market_def = {
|
||||
description = "Night Market", -- A short name for this market, appears as the text of the "info" tab of the market's UI
|
||||
long_description = "When the sun sets and the stalls of the King's Market close, other vendors are just waking up to share their wares. The Night Market is not as voluminous as the King's Market but accepts a wider range of wares. It accepts the same gold coinage of the realm, one thousand coins to the gold ingot.", -- A longer description with flavor text and other information to present to the user, shown in the info tab. Optional.
|
||||
currency = {
|
||||
["default:gold_ingot"] = 1000,
|
||||
["commoditymarket:gold_coins"] = 1
|
||||
}, -- List all items that get translated into "currency" here, along with their conversion rates. Take care to ensure there's no way for a player to multiply their money when crafting currency items into each other (eg, if there was some way to get more than 1000 coin items out of a gold ingot, in this case)
|
||||
currency_symbol = "☼", -- Used in various places in the UI. If not defined, defaults to "¤" (the generic currency symbol)
|
||||
inventory_limit = 10000, -- Optional, when set this prevents the player from adding items to their market inventory when it's over this limit
|
||||
sell_limit = 10000, -- Optional, when set this prevents sell orders from being added if the player already has this many items for sale
|
||||
initial_items = {"default:cobble", "default:wood"}, -- Optional, a list of items that the market will be initialized with on startup. Players can add other items during play.
|
||||
allow_item = function(item) return true end, -- Optional, this function is used to determine whether the market permits a player to add a particular item to its inventory.
|
||||
anonymous = true, -- If set to true then the player won't be able to see the names associated with other player's orders, only their own.
|
||||
}
|
||||
|
||||
commoditymarket.register_market("market_name", market_def)
|
||||
```
|
||||
|
||||
Once a market is defined, use `commoditymarket.show_market(market_name, player_name)` to show the market interface to a player.
|
Loading…
x
Reference in New Issue
Block a user