Module:HeroData/nav: Difference between revisionsGive feedback
Refactored for performance optimization |
Gammaton32 (talk | contribs) 3D model function |
||
| (One intermediate revision by the same user not shown) | |||
| Line 125: | Line 125: | ||
for _, hero in ipairs(heroes) do | for _, hero in ipairs(heroes) do | ||
-- Lua optimization: clean ternary fallback for page_title assignment | -- Lua optimization: clean ternary fallback for page_title assignment | ||
local page_title = subpage and (hero. | local page_title = subpage and (hero.link .. '/' .. subpage) or hero.name | ||
-- Skip redlinks entirely when enabled | -- Skip redlinks entirely when enabled | ||
| Line 131: | Line 131: | ||
local item | local item | ||
if subpage then | if subpage then | ||
item = string.format('{{PageRef|%s|alt_link=%s}}', hero. | item = string.format('{{PageRef|%s|alt_link=%s}}', hero.link, page_title) | ||
else | else | ||
item = string.format('{{HeroIcon|%s}}', hero. | item = string.format('{{HeroIcon|%s}}', hero.link) | ||
end | end | ||
table.insert(parts, item) | table.insert(parts, item) | ||
| Line 159: | Line 159: | ||
for _, hero in ipairs(heroes) do | for _, hero in ipairs(heroes) do | ||
table.insert(parts, string.format('File:%s%s|%s%s\n', hero. | table.insert(parts, string.format('File:%s%s|%s%s\n', hero.link, file_name, hero.name, description)) | ||
end | end | ||
local ret = '<gallery>\n' .. table.concat(parts) .. '</gallery>' | local ret = '<gallery>\n' .. table.concat(parts) .. '</gallery>' | ||
if debug_mode then | |||
return ret | |||
else | |||
return frame:preprocess(ret) | |||
end | |||
end | |||
-- Generate 3D model gallery | |||
function p.get_hero_models(frame) | |||
local in_herolabs = frame.args['in_herolabs'] or 'false' | |||
local debug_mode = frame.args['debug_mode'] == 'true' | |||
local heroes = get_heroes(in_herolabs) | |||
local parts = {} | |||
for _, hero in ipairs(heroes) do | |||
table.insert(parts, string.format('{{3D Model|%s}}', hero.name)) | |||
end | |||
local ret = table.concat(parts) | |||
if debug_mode then | if debug_mode then | ||