diff --git a/README.md b/README.md deleted file mode 100644 index 6388113..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# npc_talk - -Mod that actually adds NPC to yl_speak_up. \ No newline at end of file diff --git a/add_skins_and_capes.lua b/add_skins_and_capes.lua index f637f5c..de96dc3 100644 --- a/add_skins_and_capes.lua +++ b/add_skins_and_capes.lua @@ -65,11 +65,29 @@ local function add_skins_and_capes(temp, races, modname) end end + +npc_talk.add_skins_from_skinsdb = function(mob_name_string) + -- read skins from skinsdb + if(not(minetest.get_modpath("skinsdb"))) then + return + end + local list = skins.get_skinlist_for_player() + for _, skin in ipairs(list) do + -- avoid duplicate entries + if(table.indexof(yl_speak_up.mob_skins[mob_name_string], skin:get_texture()) == -1) then + table.insert(yl_speak_up.mob_skins[mob_name_string], skin:get_texture()) + end + end + minetest.log("action","[MOD] npc_talk uses "..tostring(#list).." skins from skinsdb ") +end + + -- called at startup and on reload of yl_speak_up npc_talk.add_textures = function() -- do all the things that have to be done when yl_speak_up is initialized or reloaded add_skins_and_capes(npc_talk.file_list, {"npc"}, "npc_talk:") minetest.log("action","[MOD] npc_talk loaded textures for yl_speak_up") + npc_talk.add_skins_from_skinsdb("npc_talk:npc") end -- this has to be called *once* when the file is initialized diff --git a/example_npc.lua b/example_npc.lua index 610743e..7a9a3c7 100644 --- a/example_npc.lua +++ b/example_npc.lua @@ -81,8 +81,8 @@ npc_talk.enable_talk_to_example_npc = function() end --- TODO: may require 3darmor? -if(minetest.get_modpath("mobs_npc")) then +-- we need a suitable mesh and skins from somewhere +if(minetest.get_modpath("mobs") and minetest.get_modpath("skinsdb")) then -- register the NPC once npc_talk.register_example_npc() -- make sure it gets called once now and in the future whenever yl_speak_up is reloaded diff --git a/init.lua b/init.lua index 558b673..c30eea8 100644 --- a/init.lua +++ b/init.lua @@ -4,10 +4,13 @@ local modpath = minetest.get_modpath("npc_talk")..DIR_DELIM npc_talk = {} --- a very basic NPC that doesn't require any other mods (apart from default) +-- a very basic NPC that doesn't require any other mods +-- (apart from minetest_game/player_api or any other source of +-- a mesh named character.b3d and a suitable texture named character.png) dofile(modpath .. "talking_npc.lua") --- register an example mob and a spawn egg (requires mobs_redo) +-- register an example mob and a spawn egg +-- (requires mobs_redo and skinsdb as we need some mesh and some textures from somewhere) dofile(modpath .. "example_npc.lua") -- add textures from textures/npc_talk_main_TEXTURE_NAME.png for the example npc dofile(modpath .. "add_skins_and_capes.lua") diff --git a/mod.conf b/mod.conf index 0f3e631..7a3f280 100644 --- a/mod.conf +++ b/mod.conf @@ -4,4 +4,4 @@ description = NPC for yl_speak_up release = 202309030000 title = NPC you can talk to (in combination with yl_speak_up) depends = yl_speak_up -optional_depends = mobs, mobs_npc, mobs_animal, default, player_api +optional_depends = mobs, mobs_npc, mobs_animal, default, player_api, skinsdb diff --git a/readme.md b/readme.md index fade603..eafee70 100644 --- a/readme.md +++ b/readme.md @@ -10,9 +10,12 @@ Recommends: * mobs_redo * mobs_npc * mobs_animal +* skinsdb Remember that you need the `npc_talk_owner` priv in order to configure your NPC! +This mod adds actual NPC to the game. They can be talked to on rightclick. + ## Table of Content 1. [Basic talking NPC (no other mods required)](#talking_npc) @@ -29,7 +32,7 @@ This basic NPC is available even if you install no other mods. The model - `character.b3d` - is part of `minetest_game`. You can either get it from there (you will likely have it already) or change the entry in `talking_npc.lua` to the model -your game uses. +your game uses. You will also need a texture called `character.png`. There is no spawning implemented. Type `/giveme npc_talk:talking_npc` to get one. @@ -50,13 +53,14 @@ This feature is highly experimental. The position of the sign acts as ID. -You may have to set the owner manually after placing. ### 3. Example NPC (requires mobs\_redo) This is very close to the NPC used on the Your Land server. They're basicly -`mobs_redo` based NPC. +`mobs_redo` based NPC. You also need to install the `skinsdb` mod so that +a mesh and textures are available. Technicly, `skinsdb` isn't really +necessary - but a mesh and textures are. They have to come from *somewhere*. There is no spawning implemented. Type `/giveme npc_talk:npc` to get one. @@ -71,7 +75,8 @@ Features: ### 4. Talk to existing NPC (requires mobs\_npc) These mobs come from a mod that already adds some NPC. They spawn in the world, -can be tamed with bread, and you can even breed them. +can be tamed with bread, and you can even breed them. Said mod is called +`mobs_npc`. Just right-click them to talk to and use all other features as you're used to from that mod.