mirror of
https://github.com/SmallJoker/exchange_shop.git
synced 2024-09-25 13:20:26 +02:00
Update
This commit is contained in:
parent
1d91873150
commit
3b86d9a7d5
3
init.lua
3
init.lua
|
@ -3,8 +3,7 @@ exchange_shop.storage_size = 5 * 4
|
||||||
exchange_shop.shopname = "exchange_shop:shop"
|
exchange_shop.shopname = "exchange_shop:shop"
|
||||||
|
|
||||||
-- Internationalisaton
|
-- Internationalisaton
|
||||||
--exchange_shop.S = minetest.get_translator("exchange_shop")
|
exchange_shop.S = minetest.get_translator_auto("ru")
|
||||||
exchange_shop.S = intllib.make_gettext_pair()
|
|
||||||
exchange_shop.FS = function(...)
|
exchange_shop.FS = function(...)
|
||||||
return minetest.formspec_escape(exchange_shop.S(...))
|
return minetest.formspec_escape(exchange_shop.S(...))
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,16 +6,14 @@ Set=Définir
|
||||||
You give:=Vous donnez :
|
You give:=Vous donnez :
|
||||||
You get:=Vous recevez :
|
You get:=Vous recevez :
|
||||||
Exchange=Échanger
|
Exchange=Échanger
|
||||||
You need=Vous avez besoin de
|
You need:=Vous avez besoin de
|
||||||
You give=Vous donnez
|
|
||||||
:= :
|
|
||||||
Current stock:=Stock affiché :
|
Current stock:=Stock affiché :
|
||||||
Income=Entrée
|
Income=Entrée
|
||||||
Outgoing=Sortie
|
Outgoing=Sortie
|
||||||
Use (E) + (Right click) for customer interface=Utilisez (E) + (Clic droit) pour afficher l'interface du client
|
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: "@1"=Boutique d'échange : "@1"
|
||||||
Exchange shop (owned by @1=Boutique d'échange (propriété de @1
|
Owned by @1=Propriété de @1
|
||||||
Exchange shop:=Boutique d'échange :
|
Exchange Shop:=Boutique d'échange :
|
||||||
Exchange Shop=Boutique d'échange
|
Exchange Shop=Boutique d'échange
|
||||||
Exchange shop (constructing)=Boutique d'échange (en construction)
|
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.
|
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.
|
||||||
|
|
17
locale/exchange_shop.ru.tr
Normal file
17
locale/exchange_shop.ru.tr
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# textdomain: exchange_shop
|
||||||
|
|
||||||
|
# shop.lua
|
||||||
|
Exchange Shop=Обменный Магазин
|
||||||
|
Exchange Shop:=Обменный Магазин:
|
||||||
|
Exchange Shop: "@1"=Обменный Магазин: "@1"
|
||||||
|
Owned by @1=Владелец: @1
|
||||||
|
|
||||||
|
Current stock:=Склад:
|
||||||
|
You need:=Вам нужно:
|
||||||
|
You give:=Вы отдадите:
|
||||||
|
Exchange=Обменять
|
||||||
|
You get:=Вы получите:
|
||||||
|
Income=Полученное
|
||||||
|
Outgoing=Продаваемое
|
||||||
|
Title:=Название:
|
||||||
|
Set=Устан.
|
|
@ -6,15 +6,13 @@ Set=
|
||||||
You give:=
|
You give:=
|
||||||
You get:=
|
You get:=
|
||||||
Exchange=
|
Exchange=
|
||||||
You need=
|
You need:=
|
||||||
You give=
|
|
||||||
:=
|
|
||||||
Current stock:=
|
Current stock:=
|
||||||
Income=
|
Income=
|
||||||
Outgoing=
|
Outgoing=
|
||||||
Use (E) + (Right click) for customer interface=
|
Use (E) + (Right click) for customer interface=
|
||||||
owned by @1=
|
Exchange Shop: \"@1\"=
|
||||||
Exchange shop (owned by @1=
|
Owned by @1=
|
||||||
Exchange shop:=
|
Exchange shop:=
|
||||||
Exchange Shop=
|
Exchange Shop=
|
||||||
Exchange shop (constructing)=
|
Exchange shop (constructing)=
|
||||||
|
|
132
shop.lua
132
shop.lua
|
@ -10,23 +10,26 @@ 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)
|
||||||
local name = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
local fs_prepend = default.gui_bg .. -- default.listcolors ..
|
||||||
|
"background[0,0;0,0;formspec_background_color.png^formspec_backround.png;true]"
|
||||||
|
|
||||||
|
local name = "nodemeta:" .. pos.x .. "," .. pos.y .. "," .. pos.z
|
||||||
meta = meta or minetest.get_meta(pos)
|
meta = meta or minetest.get_meta(pos)
|
||||||
|
|
||||||
local function listring(src)
|
local function listring(src)
|
||||||
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 function make_slots(x, y, list, label)
|
||||||
local arrow = "default_arrow_bg.png"
|
-- local arrow = "default_arrow_bg.png"
|
||||||
if list == "cust_ow" then
|
-- if list == "cust_ow" then
|
||||||
arrow = arrow .. "\\^\\[transformFY"
|
-- arrow = arrow .. "\\^\\[transformFY"
|
||||||
end
|
-- end
|
||||||
return table.concat({
|
return table.concat({
|
||||||
("label[%f,%f;%s]"):format(x, y - 0.6, label),
|
("label[%f,%f;%s]"):format(x, y - 0.5, 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;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),
|
-- ("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)
|
("list[" .. name .. ";%s;%f,%f;2,2;]"):format(list, x, y)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
if mode == "customer" then
|
if mode == "customer" then
|
||||||
|
@ -34,68 +37,74 @@ local function get_exchange_shop_formspec(mode, pos, meta)
|
||||||
|
|
||||||
-- customer
|
-- customer
|
||||||
local formspec = (
|
local formspec = (
|
||||||
(overflow and "size[8,9]" or "size[8,8]")..
|
"size[9,8.75]" ..
|
||||||
make_slots(1, 1, "cust_ow", FS("You give:")) ..
|
"item_image[0,-0.1;1,1;".. exchange_shop.shopname .. "]" ..
|
||||||
"button[3,2.5;2,1;exchange;" .. FS("Exchange") .. "]"..
|
"label[0.9,0.1;" .. S("Exchange Shop") .. "]" ..
|
||||||
make_slots(5, 1, "cust_og", FS("You get:"))
|
fs_prepend ..
|
||||||
|
default.gui_close_btn() ..
|
||||||
|
make_slots(1, 1.1, "cust_ow", FS("You give:")) ..
|
||||||
|
"button[3,3.2;3,1;exchange;" .. FS("Exchange") .. "]" ..
|
||||||
|
make_slots(6, 1.1, "cust_og", FS("You get:"))
|
||||||
)
|
)
|
||||||
-- Insert fallback slots
|
-- Insert fallback slots
|
||||||
local inv_pos = 4
|
local inv_pos = 4.5
|
||||||
if overflow then
|
if overflow then
|
||||||
formspec = (formspec ..
|
formspec = (formspec ..
|
||||||
"label[0.7,3.5;Ejected items:]"..
|
"label[0.7,3.5;Ejected items:]" ..
|
||||||
"label[0.7,3.8;(Remove me!)]"..
|
"label[0.7,3.8;(Remove me!)]" ..
|
||||||
"list["..name..";cust_ej;3,3.5;4,1;]"
|
"list[" .. name .. ";cust_ej;3,3.5;4,1;]"
|
||||||
)
|
)
|
||||||
inv_pos = 5
|
inv_pos = 5
|
||||||
end
|
end
|
||||||
return (formspec ..
|
return (formspec ..
|
||||||
"list[current_player;main;0," .. inv_pos .. ";8,4;]"..
|
"list[current_player;main;0," .. inv_pos .. ";9,4;]" ..
|
||||||
(overflow and listring("cust_ej") or "")
|
(overflow and listring("cust_ej") or "")
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
if mode == "owner_custm"
|
if mode == "owner_custm"
|
||||||
or mode == "owner_stock" then
|
or mode == "owner_stock" then
|
||||||
local overflow = not meta:get_inventory():is_empty("custm_ej")
|
local overflow = not meta:get_inventory():is_empty("custm_ej")
|
||||||
local title = meta:get_string("title")
|
-- local title = meta:get_string("title")
|
||||||
|
|
||||||
-- owner
|
-- owner
|
||||||
local formspec = (
|
local formspec = (
|
||||||
"size[10,10]"..
|
"size[10,10]" .. fs_prepend ..
|
||||||
"label[0,0.1;" .. FS("Title:") .. "]"..
|
"item_image[0,-0.1;1,1;".. exchange_shop.shopname .. "]" ..
|
||||||
"field[1.2,0.5;3,0.5;title;;"..title.."]"..
|
"label[0.9,0.1;" .. S("Exchange Shop") .. "]" ..
|
||||||
"field_close_on_enter[title;false]"..
|
default.gui_close_btn("9.3,-0.1") ..
|
||||||
"button[3.9,0.2;1,0.5;set_title;" .. FS("Set") .. "]"..
|
-- "field[0.3,0.65;3,0.5;title;" .. FS("Title:") .. ";" .. title .. "]" ..
|
||||||
make_slots( 0, 2, "cust_ow", FS("You need") .. FS(":")) ..
|
-- "field_close_on_enter[title;false]" ..
|
||||||
make_slots(2.5, 2, "cust_og", FS("You give") .. FS(":")) ..
|
-- "button[2.8,0.3;1,0.61;set_title;" .. FS("Set") .. "]" ..
|
||||||
"label[5,0.1;" .. FS("Current stock:") .. "]"
|
make_slots(0.1, 2, "cust_ow", FS("You need:")) ..
|
||||||
|
make_slots(2.6, 2, "cust_og", FS("You give:")) ..
|
||||||
|
"label[5,0.4;" .. FS("Current stock:") .. "]"
|
||||||
)
|
)
|
||||||
|
|
||||||
if overflow then
|
if overflow then
|
||||||
formspec = (formspec..
|
formspec = (formspec ..
|
||||||
"list["..name..";custm_ej;0.2,4;4,1;]"..
|
"list[" .. name .. ";custm_ej;0.2,4;4,1;]" ..
|
||||||
"label[0.2,4.9;Ejected items: (Remove me!)]"..
|
"label[0.2,4.9;Ejected items: (Remove me!)]" ..
|
||||||
listring("custm_ej")
|
listring("custm_ej")
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
local arrow = "default_arrow_bg.png"
|
local arrow = "default_arrow_bg.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;" .. FS("Income") .. "]"..
|
"button[6,5.25;2,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"
|
arrow = arrow .. "\\^\\[transformFY"
|
||||||
else
|
else
|
||||||
formspec = (formspec..
|
formspec = (formspec ..
|
||||||
"button[7.5,0.2;2.5,0.5;view_custm;" .. FS("Outgoing") .. "]"..
|
"button[6,5.25;2,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;" .. FS("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 .. "]" ..
|
"image[8.2,5.2;0.6,0.6;" .. arrow .. "]" ..
|
||||||
"list[current_player;main;1,6;8,4;]")
|
"list[current_player;main;0.5,6;9,4;]")
|
||||||
end
|
end
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
@ -113,7 +122,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (fields.quit and fields.quit ~= "") or
|
if (fields.quit and fields.quit ~= "") or
|
||||||
minetest.get_node(pos).name ~= "exchange_shop:shop" then
|
minetest.get_node(pos).name ~= exchange_shop.shopname then
|
||||||
shop_positions[player_name] = nil
|
shop_positions[player_name] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -122,17 +131,15 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||||
local title = meta:get_string("title")
|
local title = meta:get_string("title")
|
||||||
local shop_owner = meta:get_string("owner")
|
local shop_owner = meta:get_string("owner")
|
||||||
|
|
||||||
if fields.title and exchange_shop.has_access(meta, player_name) then
|
local ftitle = fields.title
|
||||||
|
if ftitle and exchange_shop.has_access(meta, player_name) then
|
||||||
-- Limit title length
|
-- Limit title length
|
||||||
fields.title = fields.title:sub(1, 80)
|
ftitle = ftitle:sub(1, 80)
|
||||||
if title ~= fields.title then
|
if title ~= ftitle then
|
||||||
if fields.title ~= "" then
|
local title_text = (ftitle and ftitle ~= "") and
|
||||||
meta:set_string("infotext", "'" .. fields.title
|
S("Exchange Shop: \"@1\"", ftitle) or S("Exchange Shop")
|
||||||
.. "' (" .. S("owned by @1", shop_owner) .. ")")
|
meta:set_string("infotext", title_text .. "\n" .. S("Owned by @1", shop_owner))
|
||||||
else
|
meta:set_string("title", minetest.formspec_escape(ftitle))
|
||||||
meta:set_string("infotext", S("Exchange shop (owned by @1", shop_owner) .. ")" )
|
|
||||||
end
|
|
||||||
meta:set_string("title", minetest.formspec_escape(fields.title))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -144,11 +151,11 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local err_msg, resend = exchange_shop.exchange_action(player_inv, shop_inv)
|
local err_msg, resend = exchange_shop.exchange_action(player_inv, shop_inv, pos)
|
||||||
-- 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",
|
||||||
S("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",
|
||||||
|
@ -167,7 +174,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 = S"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",
|
||||||
|
@ -180,7 +187,7 @@ 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", S("Exchange shop (owned by @1", owner) .. ")")
|
meta:set_string("infotext", S("Exchange Shop") .. "\n" .. S("Owned by @1", owner))
|
||||||
end,
|
end,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
@ -206,7 +213,7 @@ minetest.register_node(exchange_shop.shopname, {
|
||||||
S("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, _, clicker)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local player_name = clicker:get_player_name()
|
local player_name = clicker:get_player_name()
|
||||||
|
|
||||||
|
@ -219,14 +226,14 @@ minetest.register_node(exchange_shop.shopname, {
|
||||||
minetest.show_formspec(player_name, "exchange_shop:shop_formspec",
|
minetest.show_formspec(player_name, "exchange_shop:shop_formspec",
|
||||||
get_exchange_shop_formspec(mode, pos, meta))
|
get_exchange_shop_formspec(mode, pos, meta))
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
allow_metadata_inventory_move = function(pos, _, _, _, _, count, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if exchange_shop.has_access(meta, player:get_player_name()) then
|
if exchange_shop.has_access(meta, player:get_player_name()) then
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = function(pos, listname, _, 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(),
|
||||||
S("Exchange shop: Insert your trade goods into 'Outgoing'."))
|
S("Exchange shop: Insert your trade goods into 'Outgoing'."))
|
||||||
|
@ -240,7 +247,7 @@ minetest.register_node(exchange_shop.shopname, {
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_take = function(pos, listname, _, stack, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if exchange_shop.has_access(meta, player:get_player_name())
|
if exchange_shop.has_access(meta, player:get_player_name())
|
||||||
or listname == "cust_ej" then
|
or listname == "cust_ej" then
|
||||||
|
@ -251,10 +258,11 @@ minetest.register_node(exchange_shop.shopname, {
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "exchange_shop:shop",
|
output = exchange_shop.shopname,
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:sign_wall"},
|
{"default:ruby", "default:ruby", "default:ruby"},
|
||||||
{"default:chest_locked"},
|
{"default:ruby", "default:chest", "default:ruby"},
|
||||||
|
{"default:ruby", "default:ruby", "default:ruby"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ function exchange_shop.list_remove_item(inv, listname, stack)
|
||||||
return removed_stack
|
return removed_stack
|
||||||
end
|
end
|
||||||
|
|
||||||
function exchange_shop.exchange_action(player_inv, shop_inv)
|
function exchange_shop.exchange_action(player_inv, shop_inv, pos)
|
||||||
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 S("One or multiple ejection fields are filled.") .. " " ..
|
return S("One or multiple ejection fields are filled.") .. " " ..
|
||||||
|
@ -153,9 +153,10 @@ function exchange_shop.exchange_action(player_inv, shop_inv)
|
||||||
if player_inv:room_for_item("main", stack) then
|
if player_inv:room_for_item("main", stack) then
|
||||||
player_inv:add_item("main", stack)
|
player_inv:add_item("main", stack)
|
||||||
else
|
else
|
||||||
|
minetest.item_drop(stack, nil, pos)
|
||||||
-- Move to ejection field
|
-- Move to ejection field
|
||||||
shop_inv:add_item("cust_ej", stack)
|
-- shop_inv:add_item("cust_ej", stack)
|
||||||
fully_exchanged = false
|
-- fully_exchanged = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not fully_exchanged then
|
if not fully_exchanged then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user