-- Make the NPC talk (mobs_redo interface) --### -- Mob functions --### function yl_speak_up.init_mob_table() return false end function yl_speak_up.on_rightclick(self, clicker) --local item = clicker:get_wielded_item() local name = clicker:get_player_name() -- Take the mob only with net or lasso if self.owner and self.owner == name then if mobs:capture_mob(self, clicker, nil, 100, 100, true, nil) then return end end -- protect npc with mobs:protector if mobs:protect(self, clicker) then return end -- bring up the dialog options if clicker then yl_speak_up.talk(self, clicker) return end end function yl_speak_up.on_spawn(self) --Let's assign an ID -- TODO make this global mute available 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) -- TODO currently. mob_table doesn't really do anything yl_speak_up.mob_table[m_id] = "yl_speak_up:test_npc" self.yl_speak_up = { talk = m_talk, id = m_id, textures = self.textures } --Let's protect it self.protected = true self.tamed = true self.object:set_armor_groups({immortal = 100}) yl_speak_up.log_change("-", "n_"..self.yl_speak_up.id, "spawned at "..minetest.pos_to_string(self.object:get_pos()), "action") --Let's do it only once return true end function yl_speak_up.after_activate(self, staticdata, def, dtime) -- this scrolls far too much -- yl_speak_up.log_change("-", "n_"..self.yl_speak_up.id, -- "activated at "..minetest.pos_to_string(self.object:get_pos()), "action") if yl_speak_up.status == 2 then self.object:remove() return true end if self.yl_speak_up and self.yl_speak_up.skin then local tex = self.yl_speak_up.skin self.object:set_properties({textures = {tex[1], tex[2], tex[3], tex[4]}}) end if yl_speak_up.infotext then local i_text = "" if self.yl_speak_up.npc_name then i_text = i_text .. self.yl_speak_up.npc_name .. "\n" end if self.yl_speak_up.npc_description then i_text = i_text .. self.yl_speak_up.npc_description .. "\n" end i_text = i_text .. yl_speak_up.infotext self.object:set_properties({infotext = i_text}) end yl_speak_up.update_nametag(self) end