Module:Sandbox/Samlovesmath/Infobox hero: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Samlovesmath (talk | contribs) mNo edit summary |
Samlovesmath (talk | contribs) added "hero_has_tags", included "herodata" module, reintegrated "Infobox_hero.json" |
||
| Line 1: | Line 1: | ||
local p = {}; | local p = {}; | ||
local heroes_data = mw.loadJsonData("Data:HeroData.json") | local heroes_data = mw.loadJsonData("Data:HeroData.json") | ||
local theme_data = mw.loadJsonData("Data:Samlovesmath/Infobox_hero.json") | |||
local heroes_data_module = require('Module:HeroData') | |||
local | |||
function p.hero_has_tags(frame) | |||
local frame = mw.getCurrentFrame() | |||
newFrame = frame:newChild{title = "Module:HeroData", args = {frame.args[1], "1"} } | |||
if string.find(heroes_data_module.get_hero_tag(newFrame), 'Error:') == nil then | |||
return true | |||
end | |||
return false | |||
end | |||
function p.is_hero_key(frame) | function p.is_hero_key(frame) | ||
Revision as of 17:56, 15 April 2026
Documentation for this module may be created at Module:Sandbox/Samlovesmath/Infobox hero/doc
local p = {};
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local theme_data = mw.loadJsonData("Data:Samlovesmath/Infobox_hero.json")
local heroes_data_module = require('Module:HeroData')
function p.hero_has_tags(frame)
local frame = mw.getCurrentFrame()
newFrame = frame:newChild{title = "Module:HeroData", args = {frame.args[1], "1"} }
if string.find(heroes_data_module.get_hero_tag(newFrame), 'Error:') == nil then
return true
end
return false
end
function p.is_hero_key(frame)
local hero_key = frame.args[1]
for i,v in pairs(heroes_data) do
if i == hero_key then
return true
end
end
return false
end
function p.en_is_hero_key(frame)
local hero_en = frame.args[1]
for i,v in pairs(heroes_data) do
if v["Name"] ~= nil and string.lower(v["Name"]) == string.lower(hero_en) then
return true
end
end
return false
end
function p.get_theme_var(frame)
local hero_key = frame.args[1]
local theme_var = frame.args[2]
if theme_data[hero_key] ~= nil and theme_data[hero_key][theme_var] ~= nil then
return theme_data[hero_key][theme_var]
elseif theme_data["hero_default"][theme_var] ~= nil then
return theme_data["hero_default"][theme_var]
end
return nil
end
return p