1
0
Fork 0

Show villager name in trading formspec

This commit is contained in:
Wuzzy 2018-06-04 22:13:24 +02:00
parent 9bfa116794
commit a58a01040d
2 changed files with 8 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -16,7 +16,7 @@ local player_trading_with = {}
--################### VILLAGER --################### VILLAGER
--################### --###################
-- LIST OF VILLAGES PROFESSIONS AND TRADES -- LIST OF VILLAGER PROFESSIONS AND TRADES
local E1 = { "mcl_core:emerald", 1, 1 } -- one emerald local E1 = { "mcl_core:emerald", 1, 1 } -- one emerald
local professions = { local professions = {
farmer = { farmer = {
@ -361,12 +361,14 @@ local set_trade = function(self, player, inv, concrete_tradenum)
end end
local function show_trade_formspec(playername) local function show_trade_formspec(playername, trader)
local profession = professions[trader._profession].name
local formspec = local formspec =
"size[9,8.75]".. "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;mobs_mc_trading_formspec_bg.png]".. "background[-0.19,-0.25;9.41,9.49;mobs_mc_trading_formspec_bg.png]"..
mcl_vars.inventory_header.. mcl_vars.inventory_header..
"list[current_player;main;0,4.5;9,3;9]" "label[4,0;"..minetest.formspec_escape(profession).."]"
.."list[current_player;main;0,4.5;9,3;9]"
.."list[current_player;main;0,7.74;9,1;]" .."list[current_player;main;0,7.74;9,1;]"
.."button[1,1;0.5,1;prev_trade;<]" .."button[1,1;0.5,1;prev_trade;<]"
.."button[7.26,1;0.5,1;next_trade;>]" .."button[7.26,1;0.5,1;next_trade;>]"
@ -534,7 +536,7 @@ mobs:register_mob("mobs_mc:villager", {
player_tradenum[name] = 1 player_tradenum[name] = 1
set_trade(self, player, inv, player_tradenum[name]) set_trade(self, player, inv, player_tradenum[name])
show_trade_formspec(name) show_trade_formspec(name, self)
end, end,
on_spawn = function(self) on_spawn = function(self)
@ -597,7 +599,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local inv = minetest.get_inventory({type="detached", name="mobs_mc:trade"}) local inv = minetest.get_inventory({type="detached", name="mobs_mc:trade"})
set_trade(trader, player, inv, player_tradenum[name]) set_trade(trader, player, inv, player_tradenum[name])
update_offer(inv, player, false) update_offer(inv, player, false)
show_trade_formspec(name) show_trade_formspec(name, trader)
elseif fields.prev_trade then elseif fields.prev_trade then
local trader = player_trading_with[name] local trader = player_trading_with[name]
if not trader or not trader.object:get_luaentity() then if not trader or not trader.object:get_luaentity() then
@ -607,7 +609,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local inv = minetest.get_inventory({type="detached", name="mobs_mc:trade"}) local inv = minetest.get_inventory({type="detached", name="mobs_mc:trade"})
set_trade(trader, player, inv, player_tradenum[name]) set_trade(trader, player, inv, player_tradenum[name])
update_offer(inv, player, false) update_offer(inv, player, false)
show_trade_formspec(name) show_trade_formspec(name, trader)
end end
end end
end) end)