Module:Sandbox/LVL: Difference between revisions

LVL (talk | contribs)
No edit summary
LVL (talk | contribs)
No edit summary
Line 116: Line 116:
local number_int = tonumber(number_str)
local number_int = tonumber(number_str)
local localize = frame.args[4]
local localize = frame.args[4]
local hero = heroes_data[hero_name] --check if hero key is passed instead
if(hero == nil) then hero = p.get_json_item(hero_name) end --check if hero name is passed
local hero = heroes_data[hero_name]
if(hero == nil) then return "Hero Not Found" end --both invalid, error
if(hero == nil) then hero = p.get_json_item(hero_name) end
if (hero == nil) then return "Hero " .. hero_name .. " not found" end
if(hero == nil) then return "Hero Not Found" end
-- Check top-level first, then Weapon, then AltFire
local list = hero[var]
local list = hero[var]
if list == nil and hero.Weapon then
    list = hero.Weapon[var]
end
if list == nil and hero.Weapon and hero.Weapon.AltFire then
    list = hero.Weapon.AltFire[var]
end
if (list == nil) then return "" end
if (list == nil) then return "" end
local element = list[number_int]
local element = list[number_int]