hkzorman / advanced_npc

Advanced NPC for Minetest, using mobs_redo API
Other
17 stars 5 forks source link

Add npc name to initialize #58

Closed BrunoMine closed 6 years ago

BrunoMine commented 6 years ago

I want to choose names from a specific list for an npc. And do not be based simply on gender. It is possible? If it is not I want to suggest. I am now using: self.npc_name = names[math.random(1, #names)] But I believe this may be unsafe in the future. If initialization needs.

hkzorman commented 6 years ago

Right now there is a way to register names using the npc.info API. The relevant function is here: https://github.com/hkzorman/advanced_npc/blob/660f00c17da5f76fa46abfd06180cb89e8069424/info/info.lua#L14

With this function, the tags argument is an array of strings that work as metadata for that name. Essentially, they're used to pickup names on initialization. They are not limited to gender. If you want your names to be genderless, you can add to each name two tags: male and female.

However, one thing is true: npc.initialize() will only look for these two tags when finding names, and that's a limitation. Tags can be used to limit search of names to those registered by a specific mod (e.g. by adding the mod name as a tag to each name registered). This is something I have thought of: `npc.initialize' should have more support for setting certain personal info, like age, gender, texture, name, etc. I will be working on this at some point.

BrunoMine commented 6 years ago

I did not know he chooses according to the mod. Issue fixed.