Module:KeyPageData

From Library of Ruina Wiki
Jump to navigation Jump to search

Module documentation: Module:KeyPageData/doc
Data stored in Module:KeyPageData/Data
Pages using this module

Outputs key page data based on a given id or name (ID preferred, as it is faster)
Name argument is case insensitive, and ignores non-alphanumeric characters.
Example Usage:

{{#invoke:KeyPageData|getData|name|243003}}
{{#invoke:KeyPageData|getData|passives|bamboo hatted kims page}}

Bamboo-hatted Kim’s Page
SkillPurpleIcon.png Speed
Speed Dice Slot +1 (Cannot Overlap)
SkillPurpleIcon.png Singular Strike
When using a Combat Page with one non-Counter die, the die gains +2 Power, and it yields twice as many Emotion Points in a clash.
SkillOrangeIcon.png Unrelenting
Upon taking a lethal blow, reduce all incoming damage including what activated this passive by 25 for the Scene (Activates once per Act)
SkillOrangeIcon.png Swordplay of the Homeland
Slash Dice Power +2
SkillGreenIcon.png Razor Strike
Upon a successful Slash attack, inflict 1 Bleed next Scene
SkillBlueIcon.png Minimum Offense
Slash Stagger Damage +1


local getArgs = require('Module:Arguments').getArgs
local p = {}
local keypageData = mw.loadData('Module:KeyPageData/Data')

function p.getData(frame)
	if not frame then return '' end
    local ID = frame.args[2]
    local property = frame.args[1]
    if not (keypageData[ID]) then ID = frame:preprocess ( '{{ID|' .. ID .. '}}' ) end
    if not (keypageData[ID]) then return 'error: check arguments' end
	if not (keypageData[ID][property]) then return '' end
	
    if pcall(function() a=(keypageData[ID][property][1][1]) end) then
	    local s = '{{#tag: tabber|\n'
	    for k,v in pairs(keypageData[ID][property]) do
	    	s = s .. v[2] .. ' = [[file:' .. v[1] .. ']] {{!}}-{{!}}\n'
	    end
		s = s .. '}}'
		return frame:preprocess(s) or ''
    end
	return frame:preprocess(keypageData[ID][property]) or ''
end

return p