Module:Sandbox/One Bar: Difference between revisions

One Bar (talk | contribs)
m convert to string
One Bar (talk | contribs)
m null check
Line 48: Line 48:
for i=1,4 do
for i=1,4 do
local ability = ability_data[hero_key][tostring(i)]
local ability = ability_data[hero_key][tostring(i)]
hero_row:tag('td'):wikitext(ability["Name"]):done()
if (ability ~= nil) then
local ability_text = ""
hero_row:tag('td'):wikitext(ability["Name"]):done()
-- Nowhere close to all the instances of ability spirit scaling
local ability_text = ""
-- probably too much nil check but I want the table to print for now
-- Nowhere close to all the instances of ability spirit scaling
if (ability["Info1"] ~= nil and ability["Info1"]["Main"] ~= nil  
-- probably too much nil check but I want the table to print for now
and ability["Info1"]["Main"]["Props"] ~= nil) then
if (ability["Info1"] ~= nil and ability["Info1"]["Main"] ~= nil  
for _, prop in ipairs(ability["Info1"]["Main"]["Props"]) do
and ability["Info1"]["Main"]["Props"] ~= nil) then
if (prop["Scale"] ~= nil) then
for _, prop in ipairs(ability["Info1"]["Main"]["Props"]) do
ability_text = ability_text .. format_spirit_scale(frame, prop["Name"], prop["Value"], prop["Scale"]["Value"])
if (prop["Scale"] ~= nil) then
ability_text = ability_text .. format_spirit_scale(frame, prop["Name"], prop["Value"], prop["Scale"]["Value"])
end
end
else
ability_text = "-"
end
end
end
else
else
ability_text = "-"
hero_row:tag('td'):wikitext(""):done()
end
end
hero_row:tag('td'):wikitext(ability_text):done()
hero_row:tag('td'):wikitext(ability_text):done()