Compare commits

...

10 Commits

Author SHA1 Message Date
Araca
18c4dc1128
Tweaks for display of description (#17) 2024-02-02 18:45:29 +01:00
Araca
a81f58d53c
Add "description display" optional + cosmetics (#14)
* Add a checkbox to display/hide description
* Truncate the description if more than 30 characters, as for item name
* Display first line of the description instead all of it, to get the display name (Ex: "Dirt" instead of "default:dirt"). This replicates the behavior for the mod with default game.
* Display interface name of selected item below the table, instead of either full description or registered name

Co-authored-by: Florent Delord <fdelord@synthesio.com>
2024-01-28 18:47:41 +01:00
Araca
1ecf199964
Add french translation (#15)
Co-authored-by: Florent Delord <fdelord@synthesio.com>
2024-01-22 18:25:46 +01:00
Araca
bafd827d4b
Fix inventory size for mineclone2/a (#16)
Co-authored-by: Florent Delord <fdelord@synthesio.com>
2024-01-18 20:04:16 +01:00
FaceDeer
d7f26cddbf fix some spelling errors and update translation files 2023-10-02 12:53:26 -06:00
FaceDeer
5cf019ed3d
Double click workaround (#13)
* add a way to retrieve items without double-clicking

MacOS may be having a problem with double clicking, add a workaround.
Note that market orders still need double clicking to cancel, so further work is neeed.

* fix sorting of item descriptions now that there's server-side translation available

* fix Mineclone formspec
2023-01-06 20:29:34 -07:00
FaceDeer
8f47fbf010 check for mcl_formspec via get_modpath 2023-01-06 20:04:13 -07:00
BrunoMine
7a8e13c664
Add portuguese locale files (#8) 2022-02-02 18:55:53 +01:00
Nathaniel Freeman
6f994334a2
Create spanish translation (#7)
* locale

* 6^:<

Co-authored-by: PsycoJaker <psycojaker@tutanota.com>
2021-03-31 04:31:33 -06:00
FaceDeer
64f45ff557 mineclone2 has fancy formspec inventory backgrounds 2020-07-15 21:46:18 -06:00
9 changed files with 1013 additions and 73 deletions

View File

@ -1,5 +1,14 @@
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
local mcl_formspec_itemslots
local inventory_row_size = 8
if minetest.get_modpath("mcl_formspec") then
mcl_formspec_itemslots = mcl_formspec.get_itemslot_bg
end
if minetest.get_modpath("mcl_core") then
inventory_row_size = 9 -- Mineclone2/a has a different inventory size than default
end
local truncate_item_names_to = 30 local truncate_item_names_to = 30
-- Large textures can screw with the formspecs. -- Large textures can screw with the formspecs.
@ -85,23 +94,32 @@ commoditymarket.get_icon = get_icon
local truncate_string = function(target, length) local truncate_string = function(target, length)
if target:len() > length then local strip_target = minetest.strip_colors(target)
return target:sub(1,length-2).."..." if strip_target:len() > length then
return string.sub(strip_target,1,length-2).."..."
end end
return target return strip_target
end end
local get_translated_string = minetest.get_translated_string
local lang_code = nil -- it's ugly using this to pass the language code into this function, but it's efficient and works well for the sort functions.
local get_item_description = function(item) local get_item_description = function(item)
local description = S("Unknown Item")
local def = minetest.registered_items[item] local def = minetest.registered_items[item]
if def then if def then
local description = def.description description = def.description
if description then if get_translated_string then
return minetest.formspec_escape(description:gsub("\n", " ")) description = get_translated_string(lang_code, description)
end end
end end
return S("Unknown Item")
-- We keep the first line of the description, which is the game name of an item (ex: "Dirt" for the item "default:dirt")
description = description:split("\n", false, 2)[1]
return truncate_string(minetest.formspec_escape(description),truncate_item_names_to)
end end
-- Inventory formspec -- Inventory formspec
------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------
@ -110,8 +128,15 @@ local inventory_desc_comp = function(invitem1, invitem2) return invitem1.descrip
local get_account_formspec = function(market, account) local get_account_formspec = function(market, account)
local show_itemnames = account.show_itemnames == "true" local show_itemnames = account.show_itemnames == "true"
local show_descriptions = account.show_descriptions == "true"
local show_icons = global_enable_item_icons and ((account.show_icons or "true") == "true") local show_icons = global_enable_item_icons and ((account.show_icons or "true") == "true")
local market_def = market.def local market_def = market.def
if account.inventory_item_selected and not account.inventory[account.inventory_item_selected] then
-- This can happen if a player has put an item up for sale that he had previously selected in this screen,
-- thus emptying his inventory of it.
account.inventory_item_selected = nil
end
local inventory = {} local inventory = {}
local inventory_count = 0 local inventory_count = 0
@ -125,7 +150,7 @@ local get_account_formspec = function(market, account)
end end
if show_itemnames then if show_itemnames then
table.sort(inventory, inventory_item_comp) table.sort(inventory, inventory_item_comp)
else elseif show_descriptions then
table.sort(inventory, inventory_desc_comp) table.sort(inventory, inventory_desc_comp)
end end
@ -145,7 +170,10 @@ local get_account_formspec = function(market, account)
if show_itemnames then if show_itemnames then
formspec[#formspec+1] = "text;" formspec[#formspec+1] = "text;"
end end
formspec[#formspec+1] = "text;text,align=center" if show_descriptions then
formspec[#formspec+1] = "text;"
end
formspec[#formspec+1] = "text,align=center"
if show_icons then if show_icons then
formspec[#formspec+1] = ";image" formspec[#formspec+1] = ";image"
for i=2, #inventory, 2 do for i=2, #inventory, 2 do
@ -155,23 +183,32 @@ local get_account_formspec = function(market, account)
if show_itemnames then if show_itemnames then
formspec[#formspec+1] = ";text" formspec[#formspec+1] = ";text"
end end
formspec[#formspec+1] = ";text;text,align=center]" if show_descriptions then
.."tooltip[inventory;"..S("All the items you've transfered to the market to sell and the items you've\npurchased with buy orders. Double-click on an item to bring it back into your\npersonal inventory.").."]" formspec[#formspec+1] = ";text"
end
formspec[#formspec+1] = ";text,align=center]"
.."tooltip[inventory;"..S("All the items you've transferred to the market to sell and the items you've\npurchased with buy orders. Double-click on an item to bring it back into your\npersonal inventory.").."]"
.."table[0,0;9.75,4;inventory;" .."table[0,0;9.75,4;inventory;"
if show_icons then if show_icons then
formspec[#formspec+1] = "0," formspec[#formspec+1] = "0,"
end end
if show_itemnames then if show_itemnames then
formspec[#formspec+1] = S("Item").."," formspec[#formspec+1] = S("Item")..","
end end
formspec[#formspec+1] = S("Description")..","..S("Quantity") if show_descriptions then
formspec[#formspec+1] = S("Description")..","
end
formspec[#formspec+1] = S("Quantity")
if show_icons then if show_icons then
formspec[#formspec+1] = ",0" formspec[#formspec+1] = ",0"
end end
if show_itemnames then if show_itemnames then
formspec[#formspec+1] = ","..S("Item") formspec[#formspec+1] = ","..S("Item")
end end
formspec[#formspec+1] = ","..S("Description")..","..S("Quantity") if show_descriptions then
formspec[#formspec+1] = ","..S("Description")
end
formspec[#formspec+1] = ","..S("Quantity")
for i, entry in ipairs(inventory) do for i, entry in ipairs(inventory) do
if show_icons then if show_icons then
@ -179,27 +216,52 @@ local get_account_formspec = function(market, account)
end end
if show_itemnames then if show_itemnames then
formspec[#formspec+1] = "," .. truncate_string(entry.item, truncate_item_names_to) formspec[#formspec+1] = "," .. truncate_string(entry.item, truncate_item_names_to)
end end
-- no need to formspec_escape description here, it gets done when it's initially added to the inventory table if show_descriptions then
formspec[#formspec+1] = "," .. entry.description .. "," .. entry.quantity -- no need to formspec_escape description here, it gets done when it's initially added to the inventory table
formspec[#formspec+1] = "," .. entry.description
end
formspec[#formspec+1] = "," .. entry.quantity
end
formspec[#formspec+1] = "]container[0.5,4.5]"
if account.inventory_item_selected then
formspec[#formspec+1] = "button[0,0;1.3,1;retrieveitem;"..S("Retrieve:") .."]"
.."label[0,0.75;"..get_item_description(account.inventory_item_selected).."]"
end
formspec[#formspec+1] = "list[detached:commoditymarket:" .. market.name .. ";add;1.2,0;1,1;]"
.."label[2.2,0;"..S("Drop items here to\nadd to your account").."]"
.."listring[current_player;main]listring[detached:commoditymarket:" .. market.name .. ";add]"
if mcl_formspec_itemslots then
formspec[#formspec+1] = mcl_formspec_itemslots(1.2,0,1,1)
end end
formspec[#formspec+1] = "]container[1,4.5]list[detached:commoditymarket:" .. market.name .. ";add;0,0;1,1;]"
.."label[1,0;"..S("Drop items here to\nadd to your account").."]"
.."listring[current_player;main]listring[detached:commoditymarket:" .. market.name .. ";add]"
if market_def.inventory_limit then if market_def.inventory_limit then
formspec[#formspec+1] = "label[3,0;"..S("Inventory limit:").."\n" .. inventory_count.."/" .. market_def.inventory_limit .. "]" formspec[#formspec+1] = "label[4.3,0;"..S("Inventory limit:").."\n" .. inventory_count.."/" .. market_def.inventory_limit .. "]"
.. "tooltip[3,0;1.5,1;"..S("You can still receive purchased items if you've exceeded your inventory limit,\nbut you won't be able to transfer items from your personal inventory into\nthe market until you've emptied it back down below the limit again.").."]" .. "tooltip[4.2,0;1.5,1;"..S("You can still receive purchased items if you've exceeded your inventory limit,\nbut you won't be able to transfer items from your personal inventory into\nthe market until you've emptied it back down below the limit again.").."]"
end end
formspec[#formspec+1] = "label[4.9,0;"..S("Balance:") .. "\n" .. market_def.currency_symbol .. account.balance .. "]"
.."tooltip[4.9,0;3.5,1;"..S("Enter the amount of currency you'd like to withdraw then click the 'Withdraw'\nbutton to convert it into items and transfer it to your personal inventory.").."]" local x_start_inventory = 1 -- default for 8 slot per rows
.."field[6.1,0.325;1,1;withdrawamount;;]" if inventory_row_size == 9 then
x_start_inventory = 0.5
end
formspec[#formspec+1] = "label[6.1,0;"..S("Balance:") .. "\n" .. market_def.currency_symbol .. account.balance .. "]"
.."tooltip[6.1,0;3.5,1;"..S("Enter the amount of currency you'd like to withdraw then click the 'Withdraw'\nbutton to convert it into items and transfer it to your personal inventory.").."]"
.."field[7.3,0.325;1,1;withdrawamount;;]"
.."field_close_on_enter[withdrawamount;false]" .."field_close_on_enter[withdrawamount;false]"
.."button[6.7,0;1.2,1;withdraw;"..S("Withdraw").."]" .."button[7.9,0;1.2,1;withdraw;"..S("Withdraw").."]"
.."container_end[]" .."container_end[]"
.."container[1,5.75]list[current_player;main;0,0;8,1;]" .."container["..x_start_inventory..",5.75]list[current_player;main;0,0;"..inventory_row_size..",1;]"
.."list[current_player;main;0,1.25;8,3;8]container_end[]" .."list[current_player;main;0,1.25;"..inventory_row_size..",3;"..inventory_row_size.."]"
if mcl_formspec_itemslots then
formspec[#formspec+1] = mcl_formspec_itemslots(0,0,inventory_row_size,1) .. mcl_formspec_itemslots(0,1.25,inventory_row_size,3)
end
formspec[#formspec+1] = "container_end[]"
return table.concat(formspec) return table.concat(formspec)
end end
@ -212,7 +274,6 @@ local compare_market_item = function(mkt1, mkt2)
return mkt1.item < mkt2.item return mkt1.item < mkt2.item
end end
local compare_market_desc = function(mkt1, mkt2) local compare_market_desc = function(mkt1, mkt2)
-- TODO: see https://github.com/minetest/minetest/issues/8398 for sorting localized strings
return get_item_description(mkt1.item) < get_item_description(mkt2.item) return get_item_description(mkt1.item) < get_item_description(mkt2.item)
end end
local compare_buy_volume = function(mkt1, mkt2) local compare_buy_volume = function(mkt1, mkt2)
@ -315,6 +376,7 @@ local get_market_formspec = function(market, account)
local selected = account.selected local selected = account.selected
local market_list = make_marketlist(market, account) local market_list = make_marketlist(market, account)
local show_itemnames = account.show_itemnames == "true" local show_itemnames = account.show_itemnames == "true"
local show_descriptions = account.show_descriptions == "true"
local show_icons = global_enable_item_icons and ((account.show_icons or "true") == "true") local show_icons = global_enable_item_icons and ((account.show_icons or "true") == "true")
local anonymous = market_def.anonymous local anonymous = market_def.anonymous
@ -331,11 +393,14 @@ local get_market_formspec = function(market, account)
formspec[#formspec+1] = "," .. i .. "=" .. get_icon(row.item) formspec[#formspec+1] = "," .. i .. "=" .. get_icon(row.item)
end end
formspec[#formspec+1] = ";" formspec[#formspec+1] = ";"
end if show_itemnames then end
if show_itemnames then
formspec[#formspec+1] = "text;" -- itemname formspec[#formspec+1] = "text;" -- itemname
end end
formspec[#formspec+1] = "text;" -- description if show_descriptions then
.."color,span=2;" formspec[#formspec+1] = "text;" -- description
end
formspec[#formspec+1] = "color,span=2;"
.."text,align=right,tooltip="..S("Number of items there's demand for in the market.")..";" .."text,align=right,tooltip="..S("Number of items there's demand for in the market.")..";"
.."text,align=right,tooltip="..S("Maximum price being offered to buy one of these.")..";" .."text,align=right,tooltip="..S("Maximum price being offered to buy one of these.")..";"
.."color,span=2;" .."color,span=2;"
@ -352,7 +417,10 @@ local get_market_formspec = function(market, account)
if show_itemnames then if show_itemnames then
formspec[#formspec+1] = "Item," -- itemname formspec[#formspec+1] = "Item," -- itemname
end end
formspec[#formspec+1] = S("Description")..",#00FF00,"..S("Buy Vol")..","..S("Buy Max") if show_descriptions then
formspec[#formspec+1] = S("Description") .. ","
end
formspec[#formspec+1] = "#00FF00,"..S("Buy Vol")..","..S("Buy Max")
..",#FF0000,"..S("Sell Vol")..","..S("Sell Min")..","..S("Last Price")..","..S("Inventory") ..",#FF0000,"..S("Sell Vol")..","..S("Sell Min")..","..S("Last Price")..","..S("Inventory")
local selected_idx local selected_idx
@ -367,9 +435,11 @@ local get_market_formspec = function(market, account)
if show_itemnames then if show_itemnames then
formspec[#formspec+1] = "," .. truncate_string(row.item, truncate_item_names_to) formspec[#formspec+1] = "," .. truncate_string(row.item, truncate_item_names_to)
end end
if show_descriptions then
formspec[#formspec+1] = "," .. get_item_description(row.item)
end
formspec[#formspec+1] = "," .. get_item_description(row.item) formspec[#formspec+1] = ",#00FF00,"
.. ",#00FF00,"
.. row.buy_volume .. row.buy_volume
.. "," .. ((row.buy_orders[#row.buy_orders] or {}).price or "-") .. "," .. ((row.buy_orders[#row.buy_orders] or {}).price or "-")
.. ",#FF0000," .. ",#FF0000,"
@ -407,14 +477,7 @@ local get_market_formspec = function(market, account)
if selected_row then if selected_row then
local current_time = minetest.get_gametime() local current_time = minetest.get_gametime()
local desc_display local desc_display = get_item_description(selected)
if show_itemnames then
desc_display = selected
else
local def = minetest.registered_items[selected_row.item] or {description=S("Unknown Item")}
desc_display = minetest.formspec_escape(def.description:gsub("\n", " "))
end
-- player inventory for this item and for currency -- player inventory for this item and for currency
formspec[#formspec+1] = "label[0.1,5.1;"..desc_display.."\n"..S("In inventory:").." " formspec[#formspec+1] = "label[0.1,5.1;"..desc_display.."\n"..S("In inventory:").." "
.. tostring(account.inventory[selected] or 0) .."\n"..S("Balance:").." "..market_def.currency_symbol..account.balance .."]" .. tostring(account.inventory[selected] or 0) .."\n"..S("Balance:").." "..market_def.currency_symbol..account.balance .."]"
@ -436,7 +499,7 @@ local get_market_formspec = function(market, account)
-- Buy, sell, quantity and price button -- Buy, sell, quantity and price button
formspec[#formspec+1] = "tooltip[0,0.25;3.75,1;"..S("Use these fields to enter buy and sell orders for the selected item.").."]" formspec[#formspec+1] = "tooltip[0,0.25;3.75,1;"..S("Use these fields to enter buy and sell orders for the selected item.").."]"
.."button[0,0.55;1,1;buy;"..S("Buy").."]field[1.2,0.85;1,1;quantity;"..S("Quantity")..";]" .."button[0,0.55;1,1;buy;"..S("Buy").."]field[1.2,0.85;1,1;quantity;"..S("Quantity")..";]"
.."field[2.1,0.85;1,1;price;"..S("Price per")..";]button[2.7,0.55;1,1;sell;Sell]" .."field[2.1,0.85;1,1;price;"..S("Price per")..";]button[2.7,0.55;1,1;sell;"..S("Sell").."]"
.."field_close_on_enter[quantity;false]field_close_on_enter[price;false]" .."field_close_on_enter[quantity;false]field_close_on_enter[price;false]"
.."container_end[]" .."container_end[]"
-- table of buy and sell orders -- table of buy and sell orders
@ -521,7 +584,7 @@ local log_to_string = function(market, log_entry, account)
if not show_itemnames then if not show_itemnames then
local item_def = minetest.registered_items[log_entry.item] local item_def = minetest.registered_items[log_entry.item]
if item_def then if item_def then
itemname = minetest.formspec_escape(item_def.description:gsub("\n", " ")) itemname = get_item_description(log_entry.item)
end end
end end
@ -536,9 +599,9 @@ local get_info_formspec = function(market, account)
local formspec = { local formspec = {
"size[10,10]" "size[10,10]"
.."tabheader[0,0;tabs;"..market.def.description..","..S("Your Inventory")..","..S("Market Orders")..";1;false;true]" .."tabheader[0,0;tabs;"..market.def.description..","..S("Your Inventory")..","..S("Market Orders")..";1;false;true]"
.."textarea[0.75,0.5;9.25,1.5;;"..S("Description:")..";"..market.def.long_description.."]" .."textarea[0.75,0.5;9.25,2.5;;"..S("Description:")..";"..market.def.long_description.."]"
.."label[0.5,2.2;"..S("Your Recent Purchases and Sales:").."]" .."label[0.5,2.6;"..S("Your Recent Purchases and Sales:").."]"
.."textlist[0.5,2.6;8.75,4;log_entries;" .."textlist[0.5,3.1;8.75,4;log_entries;"
} }
if next(account.log) then if next(account.log) then
local new = false local new = false
@ -550,20 +613,25 @@ local get_info_formspec = function(market, account)
end end
formspec[#formspec] = "]" -- Note: there's no +1 here deliberately, that way the "]" overwrites the last comma added by the loop above. formspec[#formspec] = "]" -- Note: there's no +1 here deliberately, that way the "]" overwrites the last comma added by the loop above.
if new then if new then
formspec[#formspec+1] = "button[7.1,6.9;2,0.5;acknowledge_log;"..S("Mark logs as read").."]" .. formspec[#formspec+1] = "button[7.1,7.3;2,0.5;acknowledge_log;"..S("Mark logs as read").."]" ..
"tooltip[acknowledge_log;"..S("Log entries in yellow are new since last time you marked your log as read.").."]" "tooltip[acknowledge_log;"..S("Log entries in yellow are new since last time you marked your log as read.").."]"
end end
else else
formspec[#formspec+1] = "#CCCCCC"..S("No logged activities in this market yet.").."]" formspec[#formspec+1] = "#CCCCCC"..S("No logged activities in this market yet.").."]"
end end
local show_itemnames = account.show_itemnames or "false"
formspec[#formspec+1] = "]container[0.5, 7.5]label[0,0;Settings:]checkbox[0,0.25;show_itemnames;"..S("Show Itemnames")..";" local show_itemnames = account.show_itemnames or "false"
formspec[#formspec+1] = "]container[0.5, 7.6]label[0,0;"..S("Settings")..":]checkbox[0,0.25;show_itemnames;"..S("Show Itemnames")..";"
..show_itemnames.."]" ..show_itemnames.."]"
local show_descriptions = account.show_descriptions or "false"
formspec[#formspec+1] = "checkbox[2.1,0.25;show_descriptions;"..S("Show Descriptions")..";"..show_descriptions.."]"
if global_enable_item_icons then if global_enable_item_icons then
local show_icons = account.show_icons or "true" local show_icons = account.show_icons or "true"
formspec[#formspec+1] = "checkbox[2,0.25;show_icons;"..S("Show Icons")..";"..show_icons.."]" formspec[#formspec+1] = "checkbox[4.2,0.25;show_icons;"..S("Show Icons")..";"..show_icons.."]"
end end
formspec[#formspec+1] = "container_end[]" formspec[#formspec+1] = "container_end[]"
return table.concat(formspec) return table.concat(formspec)
@ -573,6 +641,7 @@ end
commoditymarket.get_formspec = function(market, account) commoditymarket.get_formspec = function(market, account)
local tab = account.tab local tab = account.tab
lang_code = minetest.get_player_information(account.name).lang_code
if tab == 1 then if tab == 1 then
return get_info_formspec(market, account) return get_info_formspec(market, account)
elseif tab == 2 then elseif tab == 2 then
@ -601,6 +670,21 @@ local add_to_player_inventory = function(name, item, amount)
return amount return amount
end end
local give_back_item = function(name, item, account)
local amount = account.inventory[item]
local remaining = add_to_player_inventory(name, item, amount)
if remaining == 0 then
account.inventory[item] = nil
account.inventory_item_selected = nil
else
account.inventory[item] = remaining
end
if remaining ~= amount then
return true
end
return false
end
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)
local formname_split = formname:split(":") local formname_split = formname:split(":")
@ -695,43 +779,60 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- player clicked in their inventory table, may need to give him his stuff back -- player clicked in their inventory table, may need to give him his stuff back
if fields.inventory then if fields.inventory then
local invevent = minetest.explode_table_event(fields.inventory) local invevent = minetest.explode_table_event(fields.inventory)
if invevent.type == "DCL" and invevent.column > 0 then local invevent_type = invevent.type
if invevent_type == "INV" then
-- no row selected
if account.inventory_item_selected then
account.inventory_item_selected = nil
something_changed = true
end
elseif invevent.column > 0 then
-- Find the item that was clicked on
local col_count = 8 local col_count = 8
local show_itemnames = account.show_itemnames == "true" local show_itemnames = account.show_itemnames == "true"
local show_descriptions = account.show_descriptions == "true"
if not show_itemnames then if not show_itemnames then
col_count = col_count - 2 col_count = col_count - 2
end end
if not show_icons then if not show_icons then
col_count = col_count - 2 col_count = col_count - 2
end end
if not show_descriptions then
col_count = col_count -2
end
local index = math.floor(((invevent.row-1)*col_count + invevent.column - 1)/(col_count/2)) - 1 local index = math.floor(((invevent.row-1)*col_count + invevent.column - 1)/(col_count/2)) - 1
local account = market:get_account(name) local account = market:get_account(name)
-- build a local copy of the inventory that would be displayed in the formspec so we can -- build a local copy of the inventory that would be displayed in the formspec so we can
-- figure out what item the index we were given is pointing to -- figure out what item the index we were given is pointing to
local inventory = {} local inventory = {}
lang_code = minetest.get_player_information(account.name).lang_code -- needed by get_item_description
for item, quantity in pairs(account.inventory) do for item, quantity in pairs(account.inventory) do
table.insert(inventory, {item=item, quantity=quantity, description=get_item_description(item)}) table.insert(inventory, {item=item, quantity=quantity, description=get_item_description(item)})
end end
if show_itemnames then if show_itemnames then
table.sort(inventory, inventory_item_comp) table.sort(inventory, inventory_item_comp)
else elseif show_descriptions then
table.sort(inventory, inventory_desc_comp) table.sort(inventory, inventory_desc_comp)
end end
if inventory[index] then if inventory[index] then
local item = inventory[index].item local item = inventory[index].item
local amount = account.inventory[item] if account.inventory_item_selected ~= item then
local remaining = add_to_player_inventory(name, item, amount) -- update selected item
if remaining == 0 then account.inventory_item_selected = item
account.inventory[item] = nil
else
account.inventory[item] = remaining
end
if remaining ~= amount then
something_changed = true something_changed = true
end end
if invevent_type == "DCL" then
-- double-click, give the item back immediately
something_changed = something_changed or give_back_item(name, item, account)
end
end end
end end
end end
if fields.retrieveitem and account.inventory_item_selected then
local account = market:get_account(name)
something_changed = give_back_item(name, account.inventory_item_selected, account)
end
if fields.withdraw or fields.key_enter_field == "withdrawamount" then if fields.withdraw or fields.key_enter_field == "withdrawamount" then
local withdrawvalue = tonumber(fields.withdrawamount) local withdrawvalue = tonumber(fields.withdrawamount)
@ -769,6 +870,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if process_checkbox("filter_participating", fields, account) then something_changed = true end if process_checkbox("filter_participating", fields, account) then something_changed = true end
if process_checkbox("show_itemnames", fields, account) then something_changed = true end if process_checkbox("show_itemnames", fields, account) then something_changed = true end
if process_checkbox("show_descriptions", fields, account) then something_changed = true end
if process_checkbox("show_icons", fields, account) then something_changed = true end if process_checkbox("show_icons", fields, account) then something_changed = true end
if fields.acknowledge_log then if fields.acknowledge_log then

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -22,8 +22,7 @@ User Interface: Orders=
### formspecs.lua ### ### formspecs.lua ###
#tooltip All the items you've transferred to the market to sell and the items you've@npurchased with buy orders. Double-click on an item to bring it back into your@npersonal inventory.=
All the items you've transfered to the market to sell and the items you've@npurchased with buy orders. Double-click on an item to bring it back into your@npersonal inventory.=
#tooltip #tooltip
Apply search to outputs.= Apply search to outputs.=
@ -95,6 +94,7 @@ Quantity=
#tooltip #tooltip
Quantity of this item that you have in your inventory ready to sell.= Quantity of this item that you have in your inventory ready to sell.=
Retrieve:=
Select an item to view or place orders.= Select an item to view or place orders.=
#tooltip #tooltip
@ -108,8 +108,10 @@ Sell Vol=
Sell limit:= Sell limit:=
#checkbox label #checkbox label
Show Icons= Show Icons=
Show Descriptions=
#checkbox label #checkbox label
Show Itemnames= Show Itemnames=
Settings=
The name of the player who placed this order.@nDouble-click your own orders to cancel them.= The name of the player who placed this order.@nDouble-click your own orders to cancel them.=
@ -169,8 +171,9 @@ You have too many items listed for sale in this market, please cancel some sell
list all registered markets= list all registered markets=
remove item from market. All existing buys and sells will be canceled.= remove item from market. All existing buys and sells will be cancelled.=
removes all unknown items from all markets. All existing buys and sells for those items will be canceled.= removes all unknown items from all markets. All existing buys and sells for those items will be cancelled.=
show market interface= show market interface=

View File

@ -421,7 +421,7 @@ end
minetest.register_chatcommand("market.removeitem", { minetest.register_chatcommand("market.removeitem", {
params = "marketname item", params = "marketname item",
privs = {server=true}, privs = {server=true},
description = S("remove item from market. All existing buys and sells will be canceled."), description = S("remove item from market. All existing buys and sells will be cancelled."),
func = function(name, param) func = function(name, param)
local params = param:split(" ") local params = param:split(" ")
if #params ~= 2 then if #params ~= 2 then
@ -440,7 +440,7 @@ minetest.register_chatcommand("market.removeitem", {
minetest.register_chatcommand("market.purge_unknowns", { minetest.register_chatcommand("market.purge_unknowns", {
params = "", params = "",
privs = {server=true}, privs = {server=true},
description = S("removes all unknown items from all markets. All existing buys and sells for those items will be canceled."), description = S("removes all unknown items from all markets. All existing buys and sells for those items will be cancelled."),
func = function(name, param) func = function(name, param)
for market_name, market in pairs(commoditymarket.registered_markets) do for market_name, market in pairs(commoditymarket.registered_markets) do
local items_to_remove = {} local items_to_remove = {}

View File

@ -1,3 +1,3 @@
name = commoditymarket name = commoditymarket
description = Provides API support for various in-world commodity markets description = Provides API support for various in-world commodity markets
optional_depends = doc optional_depends = doc, mcl_formspec