Module:Sandbox/Samlovesmath/Infobox hero: Difference between revisions

From The Deadlock Wiki
Jump to navigation Jump to search
Samlovesmath (talk | contribs)
Created page with "local p = {}; local heroes_data = mw.loadJsonData("Data:HeroData.json") --local theme_data = mw.loadJsonData("Data:Samlovesmath/Infobox_hero.json") -- TEMPORARY FIX local theme_data = { ["hero_default"] = { ["bg-image"] = "Default_select_background.png", ["logo-height"] = "x35px" }, ["hero_astro"] = { ["bg-image"] = "Holliday_select_background.png", ["logo-height"] = "x42px" }, ["hero_atlas"] = { ["bg-image"] = "Abrams_select_background.png", ["logo-heig..."
 
mNo edit summary
 
(5 intermediate revisions by 2 users not shown)
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 theme_data = mw.loadJsonData("Data:Sandbox/Samlovesmath/Infobox_hero.json")
-- TEMPORARY FIX
local heroes_data_module = require('Module:HeroData')
local theme_data = {
["hero_default"] = {
["bg-image"] = "Default_select_background.png",
["logo-height"] = "x35px"
},
["hero_astro"] = {
["bg-image"] = "Holliday_select_background.png",
["logo-height"] = "x42px"
},
["hero_atlas"] = {
["bg-image"] = "Abrams_select_background.png",
["logo-height"] = "x42px"
},
["hero_bebop"] = {
["bg-image"] = "Bebop_select_background.png",
["logo-height"] = "x42px"
},
["hero_bookworm"] = {
["bg-image"] = "Paige_select_background.png",
["logo-height"] = "x49px"
},
["hero_chrono"] = {
["bg-image"] = "Paradox_select_background.png",
["logo-height"] = "x28px"
},
["hero_doorman"] = {
["bg-image"] = "Doorman_select_background.png",
["logo-height"] = "x42px"
},
["hero_drifter"] = {
["bg-image"] = "Drifter_select_background.png",
["logo-height"] = "x42px"
},
["hero_dynamo"] = {
["bg-image"] = "Dynamo_select_background.png",
["logo-height"] = "x42px"
},
["hero_familiar"] = {
["bg-image"] = "Rem_select_background.png",
["logo-height"] = "x47px"
},
["hero_fencer"] = {
["bg-image"] = "Apollo_select_background.png",
["logo-height"] = "x49px"
},
["hero_forge"] = {
["bg-image"] = "Mcginnis_select_background.png",
["logo-height"] = "x42px"
},
["hero_frank"] = {
["bg-image"] = "Victor_select_background.png",
["logo-height"] = "x38px"
},
["hero_ghost"] = {
["bg-image"] = "Geist_select_background.png",
["logo-height"] = "x32px"
},
["hero_gigawatt"] = {
["bg-image"] = "Seven_select_background.png",
["logo-height"] = "x38px"
},
["hero_haze"] = {
["bg-image"] = "Haze_select_background.png",
["logo-height"] = "x24px"
},
["hero_hornet"] = {
["bg-image"] = "Vindicta_select_background.png",
["logo-height"] = "x34px"
},
["hero_inferno"] = {
["bg-image"] = "Infernus_select_background.png",
["logo-height"] = "x36px"
},
["hero_kelvin"] = {
["bg-image"] = "Kelvin_select_background.png",
["logo-height"] = "x40px"
},
["hero_krill"] = {
["bg-image"] = "Krill_select_background.png",
["logo-height"] = "x40px"
},
["hero_lash"] = {
["bg-image"] = "Lash_select_background.png",
["logo-height"] = "x42px"
},
["hero_magician"] = {
["bg-image"] = "Sinclair_select_background.png",
["logo-height"] = "x42px"
},
["hero_mirage"] = {
["bg-image"] = "Mirage_select_background.png",
["logo-height"] = "x49px"
},
["hero_nano"] = {
["bg-image"] = "Calico_select_background.png",
["logo-height"] = "x42px"
},
["hero_necro"] = {
["bg-image"] = "Graves_select_background.png",
["logo-height"] = "x36px"
},
["hero_orion"] = {
["bg-image"] = "Greytalon_select_background.png",
["logo-height"] = "x32px"
},
["hero_priest"] = {
["bg-image"] = "Venator_select_background.png",
["logo-height"] = "x40px"
},
["hero_punkgoat"] = {
["bg-image"] = "Billy_select_background.png",
["logo-height"] = "x46px"
},
["hero_shiv"] = {
["bg-image"] = "Shiv_select_background.png",
["logo-height"] = "x45px"
},
["hero_synth"] = {
["bg-image"] = "Pocket_select_background.png",
["logo-height"] = "x45px"
},
["hero_tengu"] = {
["bg-image"] = "Ivy_select_background.png",
["logo-height"] = "x45px"
},
["hero_unicorn"] = {
["bg-image"] = "Celeste_select_background.png",
["logo-height"] = "x49px"
},
["hero_vampirebat"] = {
["bg-image"] = "Mina_select_background.png",
["logo-height"] = "x45px"
},
["hero_viper"] = {
["bg-image"] = "Vyper_select_background.png",
["logo-height"] = "x45px"
},
["hero_viscous"] = {
["bg-image"] = "Viscous_select_background.png",
["logo-height"] = "x45px"
},
["hero_warden"] = {
["bg-image"] = "Warden_select_background.png",
["logo-height"] = "x30px"
},
["hero_werewolf"] = {
["bg-image"] = "Silver_select_background.png",
["logo-height"] = "x55px"
},
["hero_werewolf_transformed"] = {
["bg-image"] = "Silver_select_background.png",
["logo-height"] = "x55px"
},
["hero_wraith"] = {
["bg-image"] = "Wraith_select_background.png",
["logo-height"] = "x38px"
},
["hero_yamato"] = {
["bg-image"] = "Yamato_select_background.png",
["logo-height"] = "x32px"
}
}


function p.hero_has_scalars(frame)
local frameHero = frame.args[1]
local frameStat = frame.args[2]
local frame = mw.getCurrentFrame()
newFrameSpirit = frame:newChild{title = "Module:HeroData", args = {frameHero, "Spirit", frameStat}}
newFrameLevel = frame:newChild{title = "Module:HeroData", args = {frameHero, "Level", frameStat}}
spiritResult = heroes_data_module.get_hero_scalar(newFrameSpirit)
levelResult = heroes_data_module.get_hero_scalar(newFrameLevel)
if (spiritResult ~= nil and spiritResult ~= "") or (levelResult ~= nil and levelResult ~= "") then
return true
end
return false
end


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)
function p.en_is_hero_key(frame)

Latest revision as of 20:49, 30 July 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:Sandbox/Samlovesmath/Infobox_hero.json")
local heroes_data_module = require('Module:HeroData')

function p.hero_has_scalars(frame)
	local frameHero = frame.args[1]
	local frameStat = frame.args[2]
	local frame = mw.getCurrentFrame()
	newFrameSpirit = frame:newChild{title = "Module:HeroData", args = {frameHero, "Spirit", frameStat}}
	newFrameLevel = frame:newChild{title = "Module:HeroData", args = {frameHero, "Level", frameStat}}
	
	spiritResult = heroes_data_module.get_hero_scalar(newFrameSpirit)
	levelResult = heroes_data_module.get_hero_scalar(newFrameLevel)
	if (spiritResult ~= nil and spiritResult ~= "") or (levelResult ~= nil and levelResult ~= "") then
		return true
	end
	return false
end

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