24,527 ARTICLES
ON THIS WIKI

Module:Effect

Lua Logo.svg This is the Lua module for Template:Effect. Below is the documentation for that template.

This template is used to display Status Effects.

Syntax[edit]

{{Effect|<1>|<2>|<3>}}

Parameters[edit]

  • 1: The effect's name.
  • 2: The level of the effect. Default: 0
  • 3: The duration of the effect in seconds. Optional

Examples[edit]

Basic[edit]

{{Effect|potion.moveSpeed}}

gives...

Speed Speed

Full[edit]

{{Effect|potion.regeneration|2|80}}

gives...

Regeneration Regeneration II (1:20)


local p = {}

local g = require("Module:Common")

p.effect2name = {
	['potion.moveSpeed'] = 'Speed';
	['potion.moveSlowdown'] = 'Slowness';
	['potion.digSpeed'] = 'Haste';
	['potion.digSlowDown'] = 'Mining Fatigue';
	['potion.damageBoost'] = 'Strength';
	['potion.heal'] = 'Instant Health';
	['potion.harm'] = 'Instant Damage';
	['potion.jump'] = 'Jump Boost';
	['potion.confusion'] = 'Nausea';
	['potion.regeneration'] = 'Regeneration';
	['potion.resistance'] = 'Resistance';
	['potion.fireResistance'] = 'Fire Resistance';
	['potion.waterBreathing'] = 'Water Breathing';
	['potion.invisibility'] = 'Invisibility';
	['potion.blindness'] = 'Blindness';
	['potion.nightVision'] = 'Night Vision';
	['potion.hunger'] = 'Hunger';
	['potion.weakness'] = 'Weakness';
	['potion.poison'] = 'Poison';
	['potion.wither'] = 'Wither';
	['potion.healthBoost'] = 'Health Boost';
	['potion.absorption'] = 'Absorption';
	['potion.saturation'] = 'Saturation';
	['potion.glowing'] = 'Glowing';
	['potion.levitation'] = 'Levitation';
	['potion.luck'] = 'Luck';
	['potion.badLuck'] = 'Bad Luck';
	['potion.slowFalling'] = 'Slow Falling';
	['potion.conduitPower'] = 'Conduit Power';
	['potion.dolphinsGrace'] = "Dolphin's Grace";
	['potion.badOmen'] = 'Bad Omen';
	['potion.heroOfTheVillage'] = 'Hero of the Village';
}

p.effectNoImg = {
	-- ['potion.heal'] = true;
	-- ['potion.harm'] = true;
	-- ['potion.saturation'] = true;
}

p.effectLvl = { 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X' }

-- Returns the display name for a given effect name.
function p.getEffectName(effect)
	return p.effect2name[g.trim(effect)] or ''
end

-- Creates an effect link (with image)
function p.makeEffect(effect, level, seconds)
	effect = g.trim(effect)
	local name = p.effect2name[effect]
	if (name == nil) then
		return ''
	else
		local out = ''
		if (p.effectNoImg[effect] == nil) then
			out = out .. g.img('Effect ' .. name .. '.png', nil, 'Status Effect#' .. name, name)
		end
		if (g.isGiven(level) and tonumber(level) and tonumber(level) > 1) then
			out = out .. '&nbsp;' .. g.link('Status Effect#' .. name, name .. ' ' .. p.effectLvl[tonumber(level)])
		else
			out = out .. '&nbsp;' .. g.link('Status Effect#' .. name, name)
		end
		if (g.isGiven(seconds) and tonumber(seconds)) then
			out = out .. ' (' .. g.parseTime(tonumber(seconds)) .. ')'
		end
		return out
	end
end

-- MediaWiki wrappers around the above functions
function p.mwMakeEffect(frame) return p.makeEffect(frame.args[1], frame.args[2] or 0, frame.args[3]) end

return p