Return nil in case of error.

pull/15/head
Sane 2015-08-08 23:53:27 +02:00
parent 6a14bccd27
commit 073c80d832
1 changed files with 13 additions and 1 deletions

View File

@ -46,6 +46,7 @@ end
function skills.get_skill(name, skill_id)
-- Existing skill
local playerSkills = skills.player_skills[name]
local skill = playerSkills and playerSkills[skill_id]
if skill ~= nil then
@ -53,9 +54,20 @@ function skills.get_skill(name, skill_id)
end
-- Missing player or skill
minetest.log("info", "Requesting skill (id="..tostring(skill_id)..") for player '"..name.."'. Player is new or missing the skill.")
skills.set_default_skills(name)
return skills.player_skills[name][skill_id]
playerSkills = skills.player_skills[name]
skill = playerSkills and playerSkills[skill_id]
if playerSkills == nil then
minetest.log("error", "Failed to add default skills for player '"..name.."'.")
elseif skill == nil then
minetest.log("error", "Failed to add default skill (id="..tostring(skill_id)..") for player '"..name.."'.")
end
return skill
end
function skills.get_player_level(name)