From c7484cda2e60ec5897d0cf03346a834a3e2ef501 Mon Sep 17 00:00:00 2001 From: stujones11 Date: Fri, 17 Jul 2015 19:14:04 +0100 Subject: [PATCH] Add aliases for backwards compatibilty --- npcf/init.lua | 16 +++++++++++++--- npcf/npcf.lua | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/npcf/init.lua b/npcf/init.lua index ef65614..e8ca8f6 100644 --- a/npcf/init.lua +++ b/npcf/init.lua @@ -9,6 +9,14 @@ NPCF_ANIM_WALK = 4 NPCF_ANIM_WALK_MINE = 5 NPCF_ANIM_MINE = 6 +NPCF_ALIAS = { + ["npcf:info_npc"] = "npcf_info:npc", + ["npcf:deco_npc"] = "npcf_deco:npc", + ["npcf:builder_npc"] = "npcf_builder:npc", + ["npcf:guard_npc"] = "npcf_guard:npc", + ["npcf:trade_npc"] = "npcf_trader:npc", +} + local input = io.open(NPCF_MODPATH.."/npcf.conf", "r") if input then dofile(NPCF_MODPATH.."/npcf.conf") @@ -33,9 +41,11 @@ minetest.after(0, function() if input then local ref = minetest.deserialize(input:read('*all')) if ref then - npcf.index[id] = ref.owner - if not ref.autoload == false then - npcf:load(id) + if ref.name then + npcf.index[id] = ref.owner + if not ref.autoload then + npcf:load(id) + end end end end diff --git a/npcf/npcf.lua b/npcf/npcf.lua index 36fc2a3..f4dc852 100644 --- a/npcf/npcf.lua +++ b/npcf/npcf.lua @@ -155,6 +155,7 @@ end function npcf:add_npc(ref) if ref.id and ref.pos and ref.name then + ref.name = NPCF_ALIAS[ref.name] or ref.name local def = deepcopy(minetest.registered_entities[ref.name]) if def then ref.yaw = ref.yaw or {x=0, y=0, z=0}