tweak mobs_npc.npc_talk() ordering (function msg's > self.messages)

This commit is contained in:
tenplus1 2022-08-06 07:32:39 +01:00
parent ad21e1dd64
commit 1b3c51e336
5 changed files with 16 additions and 8 deletions

View File

@ -5,7 +5,7 @@ local S = mobs_npc.S
mobs_npc.npc_talk = function(self, player, message_list)
local name = player:get_player_name() or ""
local messages = self.messages or message_list
local messages = message_list or self.messages or {"??"}
if messages then

View File

@ -12,8 +12,6 @@ mobs_npc.igor_drops = {
"default:obsidian_shard", "default:mossycobble", {"default:obsidian", 2}
}
message_list = {"Hey!", "What do you want?", "Go away!", "Go bother someone else!"}
mobs:register_mob("mobs_npc:igor", {
type = "npc",
@ -101,7 +99,12 @@ mobs:register_mob("mobs_npc:igor", {
if mobs_npc.useDialogs == "Y" then
simple_dialogs.show_dialog_formspec(name, self)
else
mobs_npc.npc_talk(self, clicker, message_list)
if self.state == "attack" then
mobs_npc.npc_talk(self, clicker, {"Grr!", "Must Kill!"})
else
mobs_npc.npc_talk(self, clicker, {
"Hey!", "What do you want?", "Go away!", "Go bother someone else!"})
end
end
end
})

View File

@ -11,8 +11,6 @@ mobs_npc.npc_drops = {
"default:aspen_sapling", "default:permafrost_with_moss"
}
message_list = {"Hello", "Hi there", "What a lovely day"}
mobs:register_mob("mobs_npc:npc", {
type = "npc",
@ -104,7 +102,12 @@ mobs:register_mob("mobs_npc:npc", {
if mobs_npc.useDialogs == "Y" then
simple_dialogs.show_dialog_formspec(name, self)
else
mobs_npc.npc_talk(self, clicker, message_list)
if self.state == "attack" then
mobs_npc.npc_talk(self, clicker, {"Grr!"})
else
mobs_npc.npc_talk(self, clicker, {
"Hello", "Hi there", "What a lovely day"})
end
end
end
})

View File

@ -52,6 +52,8 @@ mobs_npc.drop_trade(self, player, item_to_trade, item_drop_list)
mobs_npc.npc_talk(self, player, message_list)
- Note that message_list table overrides self.messages from mob definition.
mobs_npc.shop_trade(self, player, trader_list[names, items])
mobs_npc.add_trader_list(def)

View File

@ -119,7 +119,7 @@ mobs_npc.add_trader_list = function(def)
table.insert(trader_lists, def)
end
mobs_npc.add_trader_list( {
mobs_npc.add_trader_list({
block = "default:tinblock",
nametag = "Castro",
textures = {"mobs_trader2.png"},