Return nil in case of error.
This commit is contained in:
parent
6a14bccd27
commit
073c80d832
@ -46,6 +46,7 @@ end
|
|||||||
|
|
||||||
function skills.get_skill(name, skill_id)
|
function skills.get_skill(name, skill_id)
|
||||||
-- Existing skill
|
-- Existing skill
|
||||||
|
|
||||||
local playerSkills = skills.player_skills[name]
|
local playerSkills = skills.player_skills[name]
|
||||||
local skill = playerSkills and playerSkills[skill_id]
|
local skill = playerSkills and playerSkills[skill_id]
|
||||||
if skill ~= nil then
|
if skill ~= nil then
|
||||||
@ -53,9 +54,20 @@ function skills.get_skill(name, skill_id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Missing player or skill
|
-- Missing player or skill
|
||||||
|
|
||||||
minetest.log("info", "Requesting skill (id="..tostring(skill_id)..") for player '"..name.."'. Player is new or missing the 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)
|
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
|
end
|
||||||
|
|
||||||
function skills.get_player_level(name)
|
function skills.get_player_level(name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user