Module:HeroData: Difference between revisionsGive feedback
Jump to navigation
Jump to search
m if stat not found it retusn 0 |
m get_hero_scalar |
||
| Line 25: | Line 25: | ||
return var_value | return var_value | ||
end | end | ||
--{{#invoke:HeroData|get_hero_scalar|HERO_NAME|SPIRIT_OR_LEVEL|STAT_NAME}}-- | |||
p.get_hero_scalar = function(frame) | |||
local hero_name = frame.args[1] | |||
local spirit_or_level = frame.args[2] | |||
local hero_stat_key = frame.args[3] | |||
--Ensure spirit or level is chosen | |||
if(not (spirit_or_level == "Spirit" or spirit_level == "Level")) then return "SPIRIT_OR_LEVEL must be 'Spirit' or 'Level'" end | |||
local scaling_str = spirit_or_level .. "Scaling" --i.e. SpiritScaling or LevelScaling | |||
local hero = get_json_item(hero_name) | |||
if(hero == nul) then return "Hero Not Found" end | |||
--Retrieve scaling data | |||
local hero_scaling = hero[scaling_str] | |||
if(hero_scaling == nil) then return "Hero does not have " .. scaling_str end | |||
--Retrieve scaling value | |||
local hero_scalar = hero_scaling[hero_stat_key] | |||
if(hero_scalar == nil) then return "Hero's " .. scaling_str .. " does not have the scalar " .. hero_stat_key end | |||
return hero_scalar | |||
end | |||
return p | return p | ||