mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-08-19 10:45:49 +02:00
added yl_speak_up.initialize_npc for setting n_ID
This commit is contained in:
parent
27e4da4a03
commit
471776dde4
@ -538,6 +538,30 @@ end
|
|||||||
|
|
||||||
-- Make the NPC talk
|
-- Make the NPC talk
|
||||||
|
|
||||||
|
-- assign n_ID
|
||||||
|
-- usually this happens when talking to the NPC for the first time;
|
||||||
|
-- but if you want to you can call this function earlier (on spawn)
|
||||||
|
-- so that logging of spawning with the ID is possible
|
||||||
|
yl_speak_up.initialize_npc = function(self)
|
||||||
|
-- already configured?
|
||||||
|
if(not(self) or (self.yl_speak_up and self.yl_speak_up.id)) then
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
local m_talk = yl_speak_up.talk_after_spawn or true
|
||||||
|
local m_id = yl_speak_up.number_of_npcs + 1
|
||||||
|
yl_speak_up.number_of_npcs = m_id
|
||||||
|
yl_speak_up.modstorage:set_int("amount", m_id)
|
||||||
|
|
||||||
|
self.yl_speak_up = {
|
||||||
|
talk = m_talk,
|
||||||
|
id = m_id,
|
||||||
|
textures = self.textures
|
||||||
|
}
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function yl_speak_up.talk(self, clicker)
|
function yl_speak_up.talk(self, clicker)
|
||||||
|
|
||||||
if not clicker and not clicker:is_player() then
|
if not clicker and not clicker:is_player() then
|
||||||
@ -563,15 +587,7 @@ function yl_speak_up.talk(self, clicker)
|
|||||||
|
|
||||||
-- initialize the mob if necessary; this happens at the time of first talk, not at spawn time!
|
-- initialize the mob if necessary; this happens at the time of first talk, not at spawn time!
|
||||||
elseif(not(self.yl_speak_up) or not(self.yl_speak_up.id)) then
|
elseif(not(self.yl_speak_up) or not(self.yl_speak_up.id)) then
|
||||||
local m_id = yl_speak_up.number_of_npcs + 1
|
self = yl_speak_up.initialize_npc(self)
|
||||||
yl_speak_up.number_of_npcs = m_id
|
|
||||||
yl_speak_up.modstorage:set_int("amount", m_id)
|
|
||||||
|
|
||||||
self.yl_speak_up = {
|
|
||||||
talk = true,
|
|
||||||
id = m_id,
|
|
||||||
textures = self.textures
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- create a detached inventory for the npc and load its inventory
|
-- create a detached inventory for the npc and load its inventory
|
||||||
|
Loading…
Reference in New Issue
Block a user