Please note that some information on this wiki is still based on the demo version.
If you notice any errors, feel free to correct them.

Module:Stats: Difference between revisions

From Super Fantasy Kingdom Official Wiki
wgg>Cadaei
Created page with "local p = {} function p.mainW(f) local args = Arguments.getArgs(f, { trim = true, removeBlanks = true, }) -- argument name and full name (also used for icon name) local possibleStats = {{"hp", "Health Points"}, {"shield", "Shield"}, {"pdef", "Physical Defense"}, {"mdef", "Magical Defense"}, {"dmg", "Damage"}, {"crit", "Critical Chance"}, {"range", "Range"}, {"cd", "Cooldown"}, {"aoe", "Are..."
 
wgg>Cadaei
args fix
Line 1: Line 1:
local p = {}
local p = {}


function p.mainW(f)
function p.stats(f)
local args = Arguments.getArgs(f, {
local args = f:getParent().args
trim = true,
removeBlanks = true,
})
-- argument name and full name (also used for icon name)
-- argument name and full name (also used for icon name)

Revision as of 20:55, 9 July 2023

Displays stats for units. Call with Template:Stats, code is in Module:Stats.

Parameters

  • inline: If not empty stats will be shown in one line, else in a table format
  • align: Optional, valid values are left, center or right. It will display the stats in a simple column with the stated alignment.
  • hp: Health
  • ma: Mana
  • sh: Shield
  • pd: Physical Defense
  • md: Magical Defense
  • dm: Damage
  • cr: Critical Chance
  • ra: Range
  • cd: Cooldown
  • ar: Area
  • kb: Knockback
  • sp: Speed
  • du: Duration
  • rg: Rage
  • gr: Greed
  • rr: Reroll
  • ba: Banish
  • cu: Curse

Examples

{{stats|hp=33|dm=8|sh=4|cr=2%|pd=20%|md=10%}}

Lua error at line 22: attempt to concatenate field '?' (a nil value).

{{stats|hp=20.5|ra=8.33 m|cd=1.2 s|cr=2%}}

Lua error at line 22: attempt to concatenate field '?' (a nil value).

{{stats|hp=33|dm=8|sh=4|cr=2%|pd=20%|md=10%|inline=1}}

Lua error at line 22: attempt to concatenate field '?' (a nil value).

{{stats|hp=33|dm=8|sh=4|cr=2%|pd=20%|md=10%|align=center}}

Lua error at line 22: attempt to concatenate field '?' (a nil value).

{{stats
| first = Base stats
| second = Maxed<br/>Base stats
| dm = 5
| dm2 = 6.25
| dmGain = 1
| hp = 11
| hp2 = 14.3
| hpGain = 1
| sh = 13 m
| sh2 = 16.9 m
| shGain = 2
| cr = 5%
| cr2 = 5.63%
| crGain = 1
| pd = 0%
| pd2 = 15%
| pdGain = 3
| md = 0%
| md2 = 15%
| mdGain = 3
}}

Lua error at line 22: attempt to concatenate field '?' (a nil value).


local p = {}

function p.stats(f)
	local args = f:getParent().args
	
	-- argument name and full name (also used for icon name)
	local possibleStats = {{"hp", "Health Points"},
						   {"shield", "Shield"},
						   {"pdef", "Physical Defense"},
						   {"mdef", "Magical Defense"},
						   {"dmg", "Damage"},
						   {"crit", "Critical Chance"},
						   {"range", "Range"},
						   {"cd", "Cooldown"},
						   {"aoe", "Area of Effect"}
						   }
	
	local usedStats = {}
	
	for i, s in ipairs(possibleStats) do
		if args[s[1]] then
			table.insert(usedStats, args[s[1]]..'&nbsp;[[File:'..args[s[2]]..'.png|link='..args[s[2]]..']]')
		end
	end
	
	if #usedStats == 0 then
	  return ''
	end
	
	if args.inline ~= nil then
	  -- one line, separated by bullet points
	  return table.concat(usedStats, '&bull;')
	end
	
	-- table
	return '<div style="text-align:right;display:inline-block">'..table.concat(usedStats, '<br/>')..'</div>'
end

return p