Module:AbilityData: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
Saag (talk | contribs)
mNo edit summary
Saag (talk | contribs)
build ability card template inside script
Line 28: Line 28:
--{{#invoke:ItemData|get_cost|ITEM_NAME}}--
--{{#invoke:ItemData|get_cost|ITEM_NAME}}--
p.test = function(frame)
p.test = function(frame)
     local abilityName = frame.args.abilityName
     local abilityName = frame.args[1]
     local ability = abilities[abilityName]
     local ability = abilities[abilityName]


     if ability then
     if ability then
    return ability.name
         -- Pass the table fields to the template
         -- Pass the table fields to the template
         -- return frame:expandTemplate{
         return frame:expandTemplate{
        --    title = "Ability card",
            title = "Ability card",
        --    args = {
            args = {
        --        name = ability.name,
                name = ability.name,
        --        duration = ability.duration,
                duration = ability.duration,
        --        cooldown = ability.cooldown,
                cooldown = ability.cooldown,
        --        description = ability.description,
                description = ability.description,
        --        effect1 = ability.effect1,
                effect1 = ability.effect1,
        --        effect2 = ability.effect2,
                effect2 = ability.effect2,
        --        upgrade1 = ability.upgrade1,
                upgrade1 = ability.upgrade1,
        --        upgrade2 = ability.upgrade2,
                upgrade2 = ability.upgrade2,
        --        upgrade3 = ability.upgrade3
                upgrade3 = ability.upgrade3
        --    }
            }
         -- }
         }
     else
     else
         return "Ability data not found."
         return "Ability data not found."

Revision as of 18:32, 13 September 2024

Deprecated

This module is being replaced by multiple modules in Module:Abilities. Any new functions should be created there


local p = {};
local data = mw.loadJsonData("Data:ItemData.json")

-- returns the table of a specific item
function get_json_item(name)
	for i,v in pairs(data) do
		if (v["Name"] == name) then
			return v
		end
	end
	return nil
end

local abilities = {
    shoulderCharge = {
        name = "Shoulder Charge",
        duration = "1.2s",
        cooldown = "35s",
        description = "'''Charge forward''', colliding with enemies and dragging them along. Hitting a '''wall''' will '''Stun''' enemies caught by Abrams. Speed increased after colliding with enemy Heroes.",
        effect1 = "'''Damage:''' 40 {{ss|2.1}}",
        effect2 = "'''Stun Duration:''' 0.85s",
        upgrade1 = "'''-20s''' Cooldown",
        upgrade2 = "'''+0.5s''' Duration",
        upgrade3 = "'''+5.5''' Weapon Damage for '''8s''' after colliding with an enemy"
    }
}

--{{#invoke:ItemData|get_cost|ITEM_NAME}}--
p.test = function(frame)
    local abilityName = frame.args[1]
    local ability = abilities[abilityName]

    if ability then
        -- Pass the table fields to the template
        return frame:expandTemplate{
            title = "Ability card",
            args = {
                name = ability.name,
                duration = ability.duration,
                cooldown = ability.cooldown,
                description = ability.description,
                effect1 = ability.effect1,
                effect2 = ability.effect2,
                upgrade1 = ability.upgrade1,
                upgrade2 = ability.upgrade2,
                upgrade3 = ability.upgrade3
            }
        }
    else
        return "Ability data not found."
    end
end

return p