add some feedback on success/failure

This commit is contained in:
FaceDeer 2019-08-16 02:22:56 -06:00
parent cc0908692f
commit 9492d6762e
5 changed files with 87 additions and 23 deletions

View File

@ -56,6 +56,7 @@ minetest.register_node("commoditymarket:kings_market", {
commoditymarket.show_market("kings", clicker:get_player_name())
else
minetest.chat_send_player(clicker:get_player_name(), S("At this time of day the King's Market is closed."))
minetest.sound_play({name = "commoditymarket_error", gain = 0.1, to_player=clicker:get_player_name()})
end
end,
})
@ -99,6 +100,7 @@ minetest.register_node("commoditymarket:night_market", {
commoditymarket.show_market("night", clicker:get_player_name())
else
minetest.chat_send_player(clicker:get_player_name(), S("At this time of day the Night Market is closed."))
minetest.sound_play({name = "commoditymarket_error", gain = 0.1, to_player=clicker:get_player_name()})
end
end,
})

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-16 00:40-0600\n"
"POT-Creation-Date: 2019-08-16 02:20-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -39,19 +39,19 @@ msgstr ""
msgid "At this time of day the King's Market is closed."
msgstr ""
#: commoditymarket\default_markets.lua:68
#: commoditymarket\default_markets.lua:69
msgid "Night Market"
msgstr ""
#: commoditymarket\default_markets.lua:101
#: commoditymarket\default_markets.lua:102
msgid "At this time of day the Night Market is closed."
msgstr ""
#: commoditymarket\default_markets.lua:115
#: commoditymarket\default_markets.lua:117
msgid "Trader's Caravan"
msgstr ""
#: commoditymarket\default_markets.lua:116
#: commoditymarket\default_markets.lua:118
msgid ""
"Unlike most markets that have well-known fixed locations that travelers "
"congregate to, the network of Trader's Caravans is fluid and dynamic in "
@ -62,46 +62,46 @@ msgid ""
"a location where Trader's Caravans will make a stop."
msgstr ""
#: commoditymarket\default_markets.lua:184
#: commoditymarket\default_markets.lua:186
msgid "Right-click to summon a trader's caravan"
msgstr ""
#: commoditymarket\default_markets.lua:316
#: commoditymarket\default_markets.lua:318
msgid "Trading Post"
msgstr ""
#: commoditymarket\default_markets.lua:317
#: commoditymarket\default_markets.lua:319
msgid ""
"This post signals passing caravan traders that customers can be found here, "
"and signals to customers that caravan traders can be found here. If no "
"caravan is present, right-click to summon one."
msgstr ""
#: commoditymarket\default_markets.lua:318
#: commoditymarket\default_markets.lua:320
msgid ""
"The trader's caravan requires a suitable open space next to the trading post "
"for it to arrive, and takes some time to arrive after being summoned. The "
"post gives a countdown to the caravan's arrival when moused over."
msgstr ""
#: commoditymarket\default_markets.lua:365
#: commoditymarket\default_markets.lua:367
msgid ""
"Indicated parking area isn't suitable.\n"
"A 5x3 open space with solid ground\n"
"is required for a caravan."
msgstr ""
#: commoditymarket\default_markets.lua:375
#: commoditymarket\default_markets.lua:377
msgid ""
"Caravan summoned\n"
"ETA: @1 seconds."
msgstr ""
#: commoditymarket\default_markets.lua:401
#: commoditymarket\default_markets.lua:403
msgid "Goblin Exchange"
msgstr ""
#: commoditymarket\default_markets.lua:402
#: commoditymarket\default_markets.lua:404
msgid ""
"One does not usually associate Goblins with the sort of sophistication that "
"running a market requires. Usually one just associates Goblins with savagery "
@ -113,11 +113,11 @@ msgid ""
"brokers prefer to \"keep the change\" when giving back actual coal lumps)."
msgstr ""
#: commoditymarket\default_markets.lua:433
#: commoditymarket\default_markets.lua:435
msgid "Undermarket"
msgstr ""
#: commoditymarket\default_markets.lua:434
#: commoditymarket\default_markets.lua:436
msgid ""
"Deep in the bowels of the world, below even the goblin-infested warrens and "
"ancient delvings of the dwarves, dark and mysterious beings once dwelled. A "
@ -128,18 +128,18 @@ msgid ""
"renders it useless for other purposes."
msgstr ""
#: commoditymarket\default_markets.lua:466
#: commoditymarket\default_markets.lua:468
msgid "Gold Coins"
msgstr ""
#: commoditymarket\default_markets.lua:467
#: commoditymarket\default_markets.lua:469
msgid ""
"A gold ingot is far too valuable to use as a basic unit of value, so it has "
"become common practice to divide the standard gold bar into one thousand "
"small disks to make trade easier."
msgstr ""
#: commoditymarket\default_markets.lua:468
#: commoditymarket\default_markets.lua:470
msgid ""
"Gold coins can be deposited and withdrawn from markets that accept them as "
"currency. These markets can make change if you have a thousand coins and "
@ -415,3 +415,34 @@ msgstr ""
#: commoditymarket\formspecs.lua:462
msgid "Show Itemnames"
msgstr ""
#: commoditymarket\market.lua:198
msgid ""
"You have too many items listed for sale in this market, please cancel some "
"sell orders to make room for new ones."
msgstr ""
#: commoditymarket\market.lua:200
msgid "You can't sell items for a negative price."
msgstr ""
#: commoditymarket\market.lua:202
msgid "You can't sell fewer than one item."
msgstr ""
#: commoditymarket\market.lua:204
msgid ""
"You don't have enough of that item in your inventory to post this sell order."
msgstr ""
#: commoditymarket\market.lua:295
msgid "You can't pay less than nothing for an item."
msgstr ""
#: commoditymarket\market.lua:297
msgid "You have to buy at least one item."
msgstr ""
#: commoditymarket\market.lua:299
msgid "You can't afford that many of this item."
msgstr ""

View File

@ -1,3 +1,7 @@
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
commoditymarket.registered_markets = {}
local log_length_limit = 30
@ -188,7 +192,17 @@ local add_sell = function(market, account, item, price, quantity)
end
-- validate that this sell order is possible
if sell_limit_exceeded or price < 0 or not remove_inventory_from_account(account, item, quantity) then
if sell_limit_exceeded or price < 0 or quantity < 1 or not remove_inventory_from_account(account, item, quantity) then
minetest.sound_play({name = "commoditymarket_error", gain = 0.1, to_player=account.name})
if sell_limit_exceeded then
minetest.chat_send_player(account.name, S("You have too many items listed for sale in this market, please cancel some sell orders to make room for new ones."))
elseif price < 0 then
minetest.chat_send_player(account.name, S("You can't sell items for a negative price."))
elseif quantity < 1 then
minetest.chat_send_player(account.name, S("You can't sell fewer than one item."))
else
minetest.chat_send_player(account.name, S("You don't have enough of that item in your inventory to post this sell order."))
end
return false
end
@ -230,6 +244,9 @@ local add_sell = function(market, account, item, price, quantity)
table.bininsert(sell_market, order, sell_comp)
market.orders_for_items[item].sell_volume = market.orders_for_items[item].sell_volume + quantity
end
minetest.sound_play({name = "commoditymarket_register_opened", gain = 0.1, to_player=account.name})
return true
end
local cancel_sell = function(market, item, order)
@ -241,13 +258,13 @@ local cancel_sell = function(market, item, order)
remove_order(order, sell_market)
market.orders_for_items[item].sell_volume = market.orders_for_items[item].sell_volume - quantity
add_inventory_to_account(market, account, item, quantity)
minetest.sound_play({name = "commoditymarket_register_closed", gain = 0.1, to_player=account.name})
end
-----------------------------------------------------------------------------------------------------------
local test_buy = function(market, balance, item, price, quantity)
if price < 0 or quantity < 1 then return false end
local sell_market = market.orders_for_items[item].sell_orders
local test_quantity = quantity
local test_balance = balance
@ -272,7 +289,17 @@ end
local add_buy = function(market, account, item, price, quantity)
price = tonumber(price)
quantity = tonumber(quantity)
if not test_buy(market, account.balance, item, price, quantity) then return false end
if price < 0 or quantity < 1 or not test_buy(market, account.balance, item, price, quantity) then
minetest.sound_play({name = "commoditymarket_error", gain = 0.1, to_player=account.name})
if price < 0 then
minetest.chat_send_player(account.name, S("You can't pay less than nothing for an item."))
elseif quantity < 1 then
minetest.chat_send_player(account.name, S("You have to buy at least one item."))
else
minetest.chat_send_player(account.name, S("You can't afford that many of this item."))
end
return false
end
local sell_market = market.orders_for_items[item].sell_orders
local sell_order = sell_market[#sell_market]
@ -317,6 +344,7 @@ local add_buy = function(market, account, item, price, quantity)
market.orders_for_items[item].buy_volume = market.orders_for_items[item].buy_volume + quantity
end
minetest.sound_play({name = "commoditymarket_register_opened", gain = 0.1, to_player=account.name})
return true
end
@ -331,6 +359,8 @@ local cancel_buy = function(market, item, order)
remove_order(order, buy_market)
account.balance = account.balance + price*quantity
minetest.sound_play({name = "commoditymarket_register_closed", gain = 0.1, to_player=account.name})
end
-----------------------------------------------------------------------------------------------------------

Binary file not shown.

View File

@ -1,2 +1,3 @@
commoditymarket_register_closed.ogg - from https://freesound.org/people/bspiller5/sounds/180252/ by bspiller5 under the CC-BY 3.0 license
commoditymarket_register_opened.ogg - from https://freesound.org/people/kiddpark/sounds/201159/ by kiddpark under the CC-BY 3.0 license
commoditymarket_register_opened.ogg - from https://freesound.org/people/kiddpark/sounds/201159/ by kiddpark under the CC-BY 3.0 license
commoditymarket_error.ogg - from https://freesound.org/people/LorenzoTheGreat/sounds/417794/ by LorenzoTheGreat under the CC-BY-SA 3.0 license