Add aliases for backwards compatibilty

This commit is contained in:
stujones11 2015-07-17 19:14:04 +01:00
parent a58faa6f9e
commit c7484cda2e
2 changed files with 14 additions and 3 deletions

View File

@ -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

View File

@ -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}