[1.11.4] Mobs_npc: minor fixes
This commit is contained in:
parent
5c9343c10b
commit
9cc92c5216
@ -4,13 +4,13 @@ See ../license.txt for license information.
|
|||||||
|
|
||||||
Adds Villagers (NPCs) and Traders
|
Adds Villagers (NPCs) and Traders
|
||||||
|
|
||||||
License of source code:
|
License of source code
|
||||||
-----------------------
|
----------------------
|
||||||
Copyright (C) 2016 TenPlus1
|
Copyright (C) 2016 TenPlus1
|
||||||
Copyright (C) 2019 MultiCraft Development Team
|
Copyright (C) 2019-2020 MultiCraft Development Team
|
||||||
|
|
||||||
License of textures:
|
License of textures
|
||||||
--------------------
|
-------------------
|
||||||
Copyright (C) 2019 MultiCraft Development Team
|
Copyright (C) 2019 MultiCraft Development Team
|
||||||
|
|
||||||
Graphics in this mod is NOT free and can be used only as part of the official MultiCraft build.
|
Graphics in this mod is NOT free and can be used only as part of the official MultiCraft build.
|
||||||
|
@ -13,6 +13,7 @@ Trader @1=Торговец @1
|
|||||||
<[NPC] Trader @1> Hello, @2, have a look at my wares.=<[NPC] Торговец @1> Привет, @2, посмотри, что я продаю.
|
<[NPC] Trader @1> Hello, @2, have a look at my wares.=<[NPC] Торговец @1> Привет, @2, посмотри, что я продаю.
|
||||||
Trader @1's stock=Предложения торговца @1а
|
Trader @1's stock=Предложения торговца @1а
|
||||||
Trader=Торговец
|
Trader=Торговец
|
||||||
|
Player=Игрок
|
||||||
|
|
||||||
Bill=Билл
|
Bill=Билл
|
||||||
Clark=Кларк
|
Clark=Кларк
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
mobs_trader = {}
|
||||||
|
|
||||||
|
local S = mobs_npc.S
|
||||||
local b = "blank.png"
|
local b = "blank.png"
|
||||||
|
|
||||||
mobs:register_mob("mobs_npc:trader", {
|
mobs:register_mob("mobs_npc:trader", {
|
||||||
@ -32,15 +35,15 @@ mobs:register_mob("mobs_npc:trader", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
on_punch = function(self, clicker)
|
on_punch = function(self, clicker)
|
||||||
mobs.trader_show_goods(self, clicker, mobs.human)
|
mobs_trader.trader_show_goods(self, clicker, mobs_trader.human)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
mobs.trader_show_goods(self, clicker, mobs.human)
|
mobs_trader.trader_show_goods(self, clicker, mobs_trader.human)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_spawn = function(self)
|
on_spawn = function(self)
|
||||||
self.nametag = mobs_npc.S("Trader")
|
self.nametag = S"Trader"
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
nametag = self.nametag,
|
nametag = self.nametag,
|
||||||
nametag_color = "#FFFFFF"
|
nametag_color = "#FFFFFF"
|
||||||
@ -86,7 +89,7 @@ mobs:register_mob("mobs_npc:trader", {
|
|||||||
-- inventory slots.
|
-- inventory slots.
|
||||||
|
|
||||||
-- Define tabe containing names for use and shop items for sale
|
-- Define tabe containing names for use and shop items for sale
|
||||||
mobs.human = {
|
mobs_trader.human = {
|
||||||
names = {
|
names = {
|
||||||
"Bill", "Clark", "Donald", "Duncan", "Dylan", "Ethan", "Gower",
|
"Bill", "Clark", "Donald", "Duncan", "Dylan", "Ethan", "Gower",
|
||||||
"James", "Lenny", "Ralph", "Rodman", "Scott", "Tom", "Winslow"
|
"James", "Lenny", "Ralph", "Rodman", "Scott", "Tom", "Winslow"
|
||||||
@ -135,7 +138,7 @@ mobs.human = {
|
|||||||
|
|
||||||
local random = math.random
|
local random = math.random
|
||||||
|
|
||||||
function mobs.trader_add_goods(self, race)
|
function mobs_trader.trader_add_goods(self, race)
|
||||||
local trade_index = 1
|
local trade_index = 1
|
||||||
local trades_already_added = {}
|
local trades_already_added = {}
|
||||||
local trader_pool_size = 6
|
local trader_pool_size = 6
|
||||||
@ -179,15 +182,15 @@ function mobs.trader_add_goods(self, race)
|
|||||||
self.version = 3
|
self.version = 3
|
||||||
end
|
end
|
||||||
|
|
||||||
function mobs.trader_show_goods(self, clicker, race)
|
function mobs_trader.trader_show_goods(self, clicker, race)
|
||||||
if not self.id then
|
if not self.id then
|
||||||
self.id = (random(1000) * random(10000))
|
self.id = (random(1000) * random(10000))
|
||||||
.. self.name .. (random(1000) ^ 2)
|
.. self.name .. (random(1000) ^ 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not self.game_name then
|
if not self.game_name then
|
||||||
self.game_name = mobs_npc.S(race.names[random(#race.names)])
|
self.game_name = S(race.names[random(#race.names)])
|
||||||
self.nametag = mobs_npc.S("Trader @1", self.game_name)
|
self.nametag = S("Trader @1", self.game_name)
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
nametag = self.nametag,
|
nametag = self.nametag,
|
||||||
nametag_color = "#00FF00"
|
nametag_color = "#00FF00"
|
||||||
@ -197,13 +200,13 @@ function mobs.trader_show_goods(self, clicker, race)
|
|||||||
local version = self.version
|
local version = self.version
|
||||||
|
|
||||||
if self.trades == nil or not version or version < 3 then
|
if self.trades == nil or not version or version < 3 then
|
||||||
mobs.trader_add_goods(self, race)
|
mobs_trader.trader_add_goods(self, race)
|
||||||
end
|
end
|
||||||
|
|
||||||
local player = clicker:get_player_name()
|
local player = clicker and clicker:get_player_name() or ""
|
||||||
minetest.chat_send_player(player,
|
minetest.chat_send_player(player,
|
||||||
mobs_npc.S("<[NPC] Trader @1> Hello, @2, have a look at my wares.",
|
S("<[NPC] Trader @1> Hello, @2, have a look at my wares.",
|
||||||
self.game_name, Sl(player)))
|
self.game_name, S(player)))
|
||||||
|
|
||||||
-- Make formspec trade list
|
-- Make formspec trade list
|
||||||
local formspec_trade_list = ""
|
local formspec_trade_list = ""
|
||||||
@ -247,7 +250,7 @@ function mobs.trader_show_goods(self, clicker, race)
|
|||||||
minetest.show_formspec(player, "mobs_npc:trade",
|
minetest.show_formspec(player, "mobs_npc:trade",
|
||||||
default.gui ..
|
default.gui ..
|
||||||
"item_image[0,-0.1;1,1;default:emerald]" ..
|
"item_image[0,-0.1;1,1;default:emerald]" ..
|
||||||
"label[0.9,0.1;" .. mobs_npc.S("Trader @1's stock", self.game_name) .. "]" ..
|
"label[0.9,0.1;" .. S("Trader @1's stock", self.game_name) .. "]" ..
|
||||||
"image[7.95,3.1;1.1,1.1;^[colorize:#D6D5E6]]" ..
|
"image[7.95,3.1;1.1,1.1;^[colorize:#D6D5E6]]" ..
|
||||||
formspec_trade_list)
|
formspec_trade_list)
|
||||||
end
|
end
|
||||||
@ -301,4 +304,4 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
mobs:register_egg("mobs_npc:trader", mobs_npc.S("Trader"), "mobs_trader_egg.png")
|
mobs:register_egg("mobs_npc:trader", S"Trader", "mobs_trader_egg.png")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user