forked from mtcontrib/exchange_shop
Merge remote-tracking branch 'upstream/master' into nalc-1.2-dev
This commit is contained in:
commit
0495aa6e33
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
This mod adds an improved ("currency" compatible) shop to your world.
|
This mod adds an improved ("currency" compatible) shop to your world.
|
||||||
|
|
||||||
|
Requires 5.0.0-dev or newer
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
* 4 buyer and 4 seller slots
|
* 4 buyer and 4 seller slots
|
||||||
* Much storage capacity
|
* Much storage capacity
|
||||||
@ -20,7 +22,10 @@ Optional dependencies:
|
|||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
CC0 for everything unless specified otherwise below.
|
|
||||||
|
Textures: CC0 - or see notes below
|
||||||
|
|
||||||
|
Code: MIT
|
||||||
|
|
||||||
Following textures were imported from [currency](https://github.com/minetest-mods/currency)
|
Following textures were imported from [currency](https://github.com/minetest-mods/currency)
|
||||||
* shop_front.png
|
* shop_front.png
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
default
|
|
||||||
currency?
|
|
||||||
bitchange?
|
|
||||||
wrench?
|
|
||||||
pipeworks?
|
|
||||||
tubelib?
|
|
10
init.lua
10
init.lua
@ -1,3 +1,7 @@
|
|||||||
|
if not minetest.get_translator then
|
||||||
|
error("exchange_shop requires at least Minetest 5.0.0-dev.")
|
||||||
|
end
|
||||||
|
|
||||||
exchange_shop = {}
|
exchange_shop = {}
|
||||||
exchange_shop.storage_size = 5 * 4
|
exchange_shop.storage_size = 5 * 4
|
||||||
exchange_shop.shopname = "exchange_shop:shop"
|
exchange_shop.shopname = "exchange_shop:shop"
|
||||||
@ -6,6 +10,12 @@ local modpath = minetest.get_modpath("exchange_shop")
|
|||||||
local has_currency = minetest.get_modpath("currency")
|
local has_currency = minetest.get_modpath("currency")
|
||||||
local has_bitchange = minetest.get_modpath("bitchange")
|
local has_bitchange = minetest.get_modpath("bitchange")
|
||||||
|
|
||||||
|
-- Internationalisaton
|
||||||
|
exchange_shop.S = minetest.get_translator("exchange_shop")
|
||||||
|
exchange_shop.FS = function(...)
|
||||||
|
return minetest.formspec_escape(exchange_shop.S(...))
|
||||||
|
end
|
||||||
|
|
||||||
-- Currency migrate options
|
-- Currency migrate options
|
||||||
exchange_shop.migrate = {
|
exchange_shop.migrate = {
|
||||||
use_lbm = false,
|
use_lbm = false,
|
||||||
|
35
locale/exchange_shop.fr.tr
Normal file
35
locale/exchange_shop.fr.tr
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# textdomain: exchange_shop
|
||||||
|
|
||||||
|
# shop.lua
|
||||||
|
Title:=Titre :
|
||||||
|
Set=Définir
|
||||||
|
You give:=Vous donnez :
|
||||||
|
You get:=Vous recevez :
|
||||||
|
Exchange=Échanger
|
||||||
|
You need=Vous avez besoin de
|
||||||
|
You give=Vous donnez
|
||||||
|
:= :
|
||||||
|
Current stock:=Stock affiché :
|
||||||
|
Income=Entrée
|
||||||
|
Outgoing=Sortie
|
||||||
|
Use (E) + (Right click) for customer interface=Utilisez (E) + (Clic droit) pour afficher l'interface du client
|
||||||
|
owned by @1=propriété de @1
|
||||||
|
Exchange shop (owned by @1=Boutique d'échange (propriété de @1
|
||||||
|
Exchange shop:=Boutique d'échange :
|
||||||
|
Exchange Shop=Boutique d'échange
|
||||||
|
Exchange shop (constructing)=Boutique d'échange (en construction)
|
||||||
|
Cannot dig exchange shop: one or multiple stocks are in use.=Un ou plusieurs stocks sont en cours d'utilisation, impossible d'enlever la boutique d'échange.
|
||||||
|
Exchange shop: Insert your trade goods into 'Outgoing'.=Boutique d'échange : Insérez ce que vous souhaitez échanger dans 'Sortie'
|
||||||
|
|
||||||
|
# shop_functions.lua
|
||||||
|
One or multiple ejection fields are filled.=Un ou plusieurs champs d’éjection sont remplis.
|
||||||
|
Please empty them or contact the shop owner.=Veuillez les vider ou contactez le propriétaire de la boutique.
|
||||||
|
The field '@1' can not contain multiple times the same items.=Le champ '@1' ne peux contenir plusieurs fois les mêmes éléments.
|
||||||
|
The field '@1' can not contain multiple times the same items.=Le champ '@1' ne peux contenir plusieurs fois les mêmes éléments.
|
||||||
|
Please contact the shop owner.=Veuillez contacter le propriétaire de la boutique.
|
||||||
|
The stock in this shop is full. =Le stockage de cette boutique est saturé.
|
||||||
|
Please contact the shop owner.=Veuillez contacter le propriétaire de la boutique.
|
||||||
|
This shop is sold out.=Cette boutique est en rupture de stock.
|
||||||
|
You do not have enough space in your inventory.=Vous manquez de place dans votre inventaire.
|
||||||
|
You do not have the required items.=Vous ne disposez pas des éléments demandés.
|
||||||
|
Warning! Stacks are overflowing somewhere!=Attention ! Les piles débordent quelque part !
|
35
locale/template.txt
Normal file
35
locale/template.txt
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# textdomain: exchange_shop
|
||||||
|
|
||||||
|
# shop.lua
|
||||||
|
Title:=
|
||||||
|
Set=
|
||||||
|
You give:=
|
||||||
|
You get:=
|
||||||
|
Exchange=
|
||||||
|
You need=
|
||||||
|
You give=
|
||||||
|
:=
|
||||||
|
Current stock:=
|
||||||
|
Income=
|
||||||
|
Outgoing=
|
||||||
|
Use (E) + (Right click) for customer interface=
|
||||||
|
owned by @1=
|
||||||
|
Exchange shop (owned by @1=
|
||||||
|
Exchange shop:=
|
||||||
|
Exchange Shop=
|
||||||
|
Exchange shop (constructing)=
|
||||||
|
Cannot dig exchange shop: one or multiple stocks are in use.=
|
||||||
|
Exchange shop: Insert your trade goods into 'Outgoing'.=
|
||||||
|
|
||||||
|
# shop_functions.lua
|
||||||
|
One or multiple ejection fields are filled.=
|
||||||
|
Please empty them or contact the shop owner.=
|
||||||
|
The field '@1' can not contain multiple times the same items.=
|
||||||
|
The field '@1' can not contain multiple times the same items.=
|
||||||
|
Please contact the shop owner.=
|
||||||
|
The stock in this shop is full.=
|
||||||
|
Please contact the shop owner.=
|
||||||
|
This shop is sold out.=
|
||||||
|
You do not have enough space in your inventory.=
|
||||||
|
You do not have the required items.=
|
||||||
|
Warning! Stacks are overflowing somewhere!=
|
64
shop.lua
Executable file → Normal file
64
shop.lua
Executable file → Normal file
@ -5,7 +5,8 @@ This code is based on the idea of Dan Duncombe's exchange shop
|
|||||||
https://web.archive.org/web/20160403113102/https://forum.minetest.net/viewtopic.php?id=7002
|
https://web.archive.org/web/20160403113102/https://forum.minetest.net/viewtopic.php?id=7002
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
local S = exchange_shop.S
|
||||||
|
local FS = exchange_shop.FS
|
||||||
local shop_positions = {}
|
local shop_positions = {}
|
||||||
|
|
||||||
local function get_exchange_shop_formspec(mode, pos, meta)
|
local function get_exchange_shop_formspec(mode, pos, meta)
|
||||||
@ -16,17 +17,27 @@ local function get_exchange_shop_formspec(mode, pos, meta)
|
|||||||
return "listring[".. name ..";" .. src .. "]" ..
|
return "listring[".. name ..";" .. src .. "]" ..
|
||||||
"listring[current_player;main]"
|
"listring[current_player;main]"
|
||||||
end
|
end
|
||||||
|
local function make_slots(x, y, list, label)
|
||||||
|
local arrow = "exchange_shop_arrow.png"
|
||||||
|
if list == "cust_ow" then
|
||||||
|
arrow = arrow .. "\\^\\[transformFY"
|
||||||
|
end
|
||||||
|
return table.concat({
|
||||||
|
("label[%f,%f;%s]"):format(x, y - 0.6, label),
|
||||||
|
("image[%f,%f;0.6,0.6;shop_front.png]"):format(x + 0.15, y + 0.3),
|
||||||
|
("image[%f,%f;0.6,0.6;%s]"):format(x + 0.15, y + 0.0, arrow),
|
||||||
|
("list["..name..";%s;%f,%f;2,2;]"):format(list, x, y)
|
||||||
|
})
|
||||||
|
end
|
||||||
if mode == "customer" then
|
if mode == "customer" then
|
||||||
local overflow = not meta:get_inventory():is_empty("cust_ej")
|
local overflow = not meta:get_inventory():is_empty("cust_ej")
|
||||||
|
|
||||||
-- customer
|
-- customer
|
||||||
local formspec = (
|
local formspec = (
|
||||||
(overflow and "size[8,9]" or "size[8,8]")..
|
(overflow and "size[8,9]" or "size[8,8]")..
|
||||||
"label[1,0.4;You give:]"..
|
make_slots(1, 1, "cust_ow", FS("You give:")) ..
|
||||||
"list["..name..";cust_ow;1,1;2,2;]"..
|
"button[3,2.5;2,1;exchange;" .. FS("Exchange") .. "]"..
|
||||||
"button[3,2.4;2,1;exchange;Exchange]"..
|
make_slots(5, 1, "cust_og", FS("You get:"))
|
||||||
"label[5,0.4;You get:]"..
|
|
||||||
"list["..name..";cust_og;5,1;2,2;]"
|
|
||||||
)
|
)
|
||||||
-- Insert fallback slots
|
-- Insert fallback slots
|
||||||
local inv_pos = 4
|
local inv_pos = 4
|
||||||
@ -51,17 +62,13 @@ local function get_exchange_shop_formspec(mode, pos, meta)
|
|||||||
-- owner
|
-- owner
|
||||||
local formspec = (
|
local formspec = (
|
||||||
"size[10,10]"..
|
"size[10,10]"..
|
||||||
"label[0,0.1;Title:]"..
|
"label[0,0.1;" .. FS("Title:") .. "]"..
|
||||||
"field[1.2,0.5;3,0.5;title;;"..title.."]"..
|
"field[1.2,0.5;3,0.5;title;;"..title.."]"..
|
||||||
"field_close_on_enter[title;false]"..
|
"field_close_on_enter[title;false]"..
|
||||||
"button[3.9,0.2;1,0.5;set_title;Set]"..
|
"button[3.9,0.2;1,0.5;set_title;" .. FS("Set") .. "]"..
|
||||||
"container[0,2]"..
|
make_slots( 0, 2, "cust_ow", FS("You need") .. FS(":")) ..
|
||||||
"label[0,-0.6;You need:]"..
|
make_slots(2.5, 2, "cust_og", FS("You give") .. FS(":")) ..
|
||||||
"list["..name..";cust_ow;0,0;2,2;]"..
|
"label[5,0.1;" .. FS("Current stock:") .. "]"
|
||||||
"label[2.5,-0.6;You give:]"..
|
|
||||||
"list["..name..";cust_og;2.5,0;2,2;]"..
|
|
||||||
"container_end[]"..
|
|
||||||
"label[5,0.1;Current stock:]"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if overflow then
|
if overflow then
|
||||||
@ -72,19 +79,22 @@ local function get_exchange_shop_formspec(mode, pos, meta)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local arrow = "exchange_shop_arrow.png"
|
||||||
if mode == "owner_custm" then
|
if mode == "owner_custm" then
|
||||||
formspec = (formspec..
|
formspec = (formspec..
|
||||||
"button[7.5,0.2;2.5,0.5;view_stock;Income]"..
|
"button[7.5,0.2;2.5,0.5;view_stock;" .. FS("Income") .. "]"..
|
||||||
"list["..name..";custm;5,1;5,4;]"..
|
"list["..name..";custm;5,1;5,4;]"..
|
||||||
listring("custm"))
|
listring("custm"))
|
||||||
|
arrow = arrow .. "\\^\\[transformFY"
|
||||||
else
|
else
|
||||||
formspec = (formspec..
|
formspec = (formspec..
|
||||||
"button[7.5,0.2;2.5,0.5;view_custm;Outgoing]"..
|
"button[7.5,0.2;2.5,0.5;view_custm;" .. FS("Outgoing") .. "]"..
|
||||||
"list["..name..";stock;5,1;5,4;]"..
|
"list["..name..";stock;5,1;5,4;]"..
|
||||||
listring("stock"))
|
listring("stock"))
|
||||||
end
|
end
|
||||||
return (formspec..
|
return (formspec..
|
||||||
"label[1,5.4;Use (E) + (Right click) for customer interface]"..
|
"label[1,5.4;" .. FS("Use (E) + (Right click) for customer interface") .. "]"..
|
||||||
|
"image[8.2,5.2;0.6,0.6;" .. arrow .. "]" ..
|
||||||
"list[current_player;main;1,6;8,4;]")
|
"list[current_player;main;1,6;8,4;]")
|
||||||
end
|
end
|
||||||
return ""
|
return ""
|
||||||
@ -118,10 +128,9 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
|||||||
if title ~= fields.title then
|
if title ~= fields.title then
|
||||||
if fields.title ~= "" then
|
if fields.title ~= "" then
|
||||||
meta:set_string("infotext", "'" .. fields.title
|
meta:set_string("infotext", "'" .. fields.title
|
||||||
.. "' (owned by " .. shop_owner .. ")")
|
.. "' (" .. S("owned by @1", shop_owner) .. ")")
|
||||||
else
|
else
|
||||||
meta:set_string("infotext", "Exchange shop (owned by "
|
meta:set_string("infotext", S("Exchange shop (owned by @1", shop_owner) .. ")" )
|
||||||
.. shop_owner ..")")
|
|
||||||
end
|
end
|
||||||
meta:set_string("title", minetest.formspec_escape(fields.title))
|
meta:set_string("title", minetest.formspec_escape(fields.title))
|
||||||
end
|
end
|
||||||
@ -139,7 +148,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
|||||||
-- Throw error message
|
-- Throw error message
|
||||||
if err_msg then
|
if err_msg then
|
||||||
minetest.chat_send_player(player_name, minetest.colorize("#F33",
|
minetest.chat_send_player(player_name, minetest.colorize("#F33",
|
||||||
"Exchange shop: " .. err_msg))
|
S("Exchange shop:") .. " " .. err_msg))
|
||||||
end
|
end
|
||||||
if resend then
|
if resend then
|
||||||
minetest.show_formspec(player_name, "exchange_shop:shop_formspec",
|
minetest.show_formspec(player_name, "exchange_shop:shop_formspec",
|
||||||
@ -158,7 +167,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_node(exchange_shop.shopname, {
|
minetest.register_node(exchange_shop.shopname, {
|
||||||
description = "Exchange Shop",
|
description = S"Exchange Shop",
|
||||||
tiles = {
|
tiles = {
|
||||||
"shop_top.png", "shop_top.png",
|
"shop_top.png", "shop_top.png",
|
||||||
"shop_side.png","shop_side.png",
|
"shop_side.png","shop_side.png",
|
||||||
@ -171,12 +180,11 @@ minetest.register_node(exchange_shop.shopname, {
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
meta:set_string("owner", owner)
|
meta:set_string("owner", owner)
|
||||||
meta:set_string("infotext", "Exchange shop (owned by "
|
meta:set_string("infotext", S("Exchange shop (owned by @1", owner) .. ")")
|
||||||
.. owner .. ")")
|
|
||||||
end,
|
end,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("infotext", "Exchange shop (constructing)")
|
meta:set_string("infotext", S("Exchange shop (constructing)"))
|
||||||
meta:set_string("owner", "")
|
meta:set_string("owner", "")
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("stock", exchange_shop.storage_size) -- needed stock for exchanges
|
inv:set_size("stock", exchange_shop.storage_size) -- needed stock for exchanges
|
||||||
@ -195,7 +203,7 @@ minetest.register_node(exchange_shop.shopname, {
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(player:get_player_name(),
|
minetest.chat_send_player(player:get_player_name(),
|
||||||
"Cannot dig exchange shop: one or multiple stocks are in use.")
|
S("Cannot dig exchange shop: one or multiple stocks are in use."))
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(pos, node, clicker, itemstack)
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||||||
@ -221,7 +229,7 @@ minetest.register_node(exchange_shop.shopname, {
|
|||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
if listname == "custm" then
|
if listname == "custm" then
|
||||||
minetest.chat_send_player(player:get_player_name(),
|
minetest.chat_send_player(player:get_player_name(),
|
||||||
"Exchange shop: Insert your trade goods into 'Outgoing'.")
|
S("Exchange shop: Insert your trade goods into 'Outgoing'."))
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
local S = exchange_shop.S
|
||||||
|
|
||||||
function exchange_shop.has_access(meta, player_name)
|
function exchange_shop.has_access(meta, player_name)
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
if player_name == owner or owner == "" then
|
if player_name == owner or owner == "" then
|
||||||
@ -67,8 +69,8 @@ end
|
|||||||
function exchange_shop.exchange_action(player_inv, shop_inv)
|
function exchange_shop.exchange_action(player_inv, shop_inv)
|
||||||
if not shop_inv:is_empty("cust_ej")
|
if not shop_inv:is_empty("cust_ej")
|
||||||
or not shop_inv:is_empty("custm_ej") then
|
or not shop_inv:is_empty("custm_ej") then
|
||||||
return "One or multiple ejection fields are filled. "..
|
return S("One or multiple ejection fields are filled.") .. " " ..
|
||||||
"Please empty them or contact the shop owner."
|
S("Please empty them or contact the shop owner.")
|
||||||
end
|
end
|
||||||
local owner_wants = shop_inv:get_list("cust_ow")
|
local owner_wants = shop_inv:get_list("cust_ow")
|
||||||
local owner_gives = shop_inv:get_list("cust_og")
|
local owner_gives = shop_inv:get_list("cust_og")
|
||||||
@ -81,8 +83,8 @@ function exchange_shop.exchange_action(player_inv, shop_inv)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
if i1 ~= i2 and name1 == item2:get_name() then
|
if i1 ~= i2 and name1 == item2:get_name() then
|
||||||
return "The field 'Owner needs' can not contain multiple "..
|
return S("The field '@1' can not contain multiple times the same items.", S("You need")) .. " " ..
|
||||||
"times the same items. Please contact the shop owner."
|
S("Please contact the shop owner.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -95,8 +97,8 @@ function exchange_shop.exchange_action(player_inv, shop_inv)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
if i1 ~= i2 and name1 == item2:get_name() then
|
if i1 ~= i2 and name1 == item2:get_name() then
|
||||||
return "The field 'Owner gives' can not contain multiple "..
|
return S("The field '@1' can not contain multiple times the same items.", S("You give")) .. " " ..
|
||||||
"times the same items. Please contact the shop owner."
|
S("Please contact the shop owner.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -104,8 +106,8 @@ function exchange_shop.exchange_action(player_inv, shop_inv)
|
|||||||
-- Check for space in the shop
|
-- Check for space in the shop
|
||||||
for i, item in pairs(owner_wants) do
|
for i, item in pairs(owner_wants) do
|
||||||
if not shop_inv:room_for_item("custm", item) then
|
if not shop_inv:room_for_item("custm", item) then
|
||||||
return "The stock in this shop is full. "..
|
return S("The stock in this shop is full.") .. " " ..
|
||||||
"Please contact the shop owner."
|
S("Please contact the shop owner.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -114,21 +116,21 @@ function exchange_shop.exchange_action(player_inv, shop_inv)
|
|||||||
-- Check availability of the shop's items
|
-- Check availability of the shop's items
|
||||||
for i, item in pairs(owner_gives) do
|
for i, item in pairs(owner_gives) do
|
||||||
if not list_contains_item(shop_inv, "stock", item) then
|
if not list_contains_item(shop_inv, "stock", item) then
|
||||||
return "This shop is sold out."
|
return S("This shop is sold out.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check for space in the player's inventory
|
-- Check for space in the player's inventory
|
||||||
for i, item in pairs(owner_gives) do
|
for i, item in pairs(owner_gives) do
|
||||||
if not player_inv:room_for_item("main", item) then
|
if not player_inv:room_for_item("main", item) then
|
||||||
return "You do not have enough space in your inventory."
|
return S("You do not have enough space in your inventory.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check availability of the player's items
|
-- Check availability of the player's items
|
||||||
for i, item in pairs(owner_wants) do
|
for i, item in pairs(owner_wants) do
|
||||||
if not list_contains_item(player_inv, "main", item) then
|
if not list_contains_item(player_inv, "main", item) then
|
||||||
return "You do not have the required items."
|
return S("You do not have the required items.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -157,6 +159,6 @@ function exchange_shop.exchange_action(player_inv, shop_inv)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not fully_exchanged then
|
if not fully_exchanged then
|
||||||
return "Warning! Stacks are overflowing somewhere!", true
|
return S("Warning! Stacks are overflowing somewhere!"), true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
BIN
textures/exchange_shop_arrow.png
Normal file
BIN
textures/exchange_shop_arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 438 B |
Loading…
x
Reference in New Issue
Block a user