More actions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = { | ||
split = function(str, sep) | |||
if (str == nil) then return {} end | |||
local result = {} | |||
for match in (str..sep):gmatch("([^"..sep.."]+)") do | |||
table.insert(result, match) | |||
end | |||
return result | |||
end | |||
} | |||
function p.attributes( frame ) | function p.attributes( frame ) | ||
Line 10: | Line 19: | ||
local attr = args[v] or args[v:lower()] | local attr = args[v] or args[v:lower()] | ||
if attr ~= nil then | if attr ~= nil then | ||
local attrName = attr:lower() | local attrName = p.split(attr:lower(), "_") | ||
for j, k in ipairs(attrName) do | for j, k in ipairs(attrName) do | ||
attrName[j] = k:sub(1, 1):upper() .. k:sub(2) | attrName[j] = k:sub(1, 1):upper() .. k:sub(2) | ||
end | end | ||
attrName = table.concat(attrName, " ") | attrName = table.concat(attrName, " ") | ||
local attrValue = tonumber( | local attrValue = tonumber(p.split(attr, ";")[1]) | ||
if attrValue then | if attrValue then | ||
local operator = | local operator = p.split(attr, ";")[2] or "0" | ||
if operator == "1" then | if operator == "1" then | ||
operator = "%" | operator = "%" | ||
Line 48: | Line 57: | ||
for i, v in ipairs(args) do | for i, v in ipairs(args) do | ||
local keybindInfo = args[v] | local keybindInfo = p.split(args[v], ";") | ||
local keybindLabel = keybindInfo[1] | local keybindLabel = keybindInfo[1] | ||
local keybindSlot = tonumber(keybindInfo[2]) | local keybindSlot = tonumber(keybindInfo[2]) |
Revision as of 07:17, 13 April 2025
Documentation for this module may be created at Module:HeroInfo/doc
local p = {
split = function(str, sep)
if (str == nil) then return {} end
local result = {}
for match in (str..sep):gmatch("([^"..sep.."]+)") do
table.insert(result, match)
end
return result
end
}
function p.attributes( frame )
local attributeList = {"ARROW_DAMAGE", "BASE_SPEED", "BASE_SPEED_LEVELS", "BOW_DRAWBACK", "DAMAGE_REDUCTION", "FALL_RESISTANCE", "FISKTAG_ARMOR", "FISKTAG_HEALTH", "IMPACT_DAMAGE", "JUMP_HEIGHT", "KNOCKBACK", "MAX_HEALTH", "PUNCH_DAMAGE", "REACH_DISTANCE", "SPRINT_SPEED", "STEP_HEIGHT", "WEAPON_DAMAGE"}
local args = frame.args
local out = {}
for i, v in ipairs(attributeList) do
local attr = args[v] or args[v:lower()]
if attr ~= nil then
local attrName = p.split(attr:lower(), "_")
for j, k in ipairs(attrName) do
attrName[j] = k:sub(1, 1):upper() .. k:sub(2)
end
attrName = table.concat(attrName, " ")
local attrValue = tonumber(p.split(attr, ";")[1])
if attrValue then
local operator = p.split(attr, ";")[2] or "0"
if operator == "1" then
operator = "%"
end
local positive
if (tonumber(attrValue) > 0) then
positive = "+"
end
table.insert(out, "* " .. positive .. attrValue .. operator .. " " .. attrName)
end
end
end
return table.concat(out, "\n")
end
function p.keybinds( frame )
local keybindCodes = {}
keybindCodes[-1] = "Left Click"
for i = 1, 5 do
keybindCodes[i] = "Ability " .. i
end
local modifiers = {"sneaking", "on the ground", "in the air", "flying"}
local args = frame.args
local out = {}
for i, v in ipairs(args) do
local keybindInfo = p.split(args[v], ";")
local keybindLabel = keybindInfo[1]
local keybindSlot = tonumber(keybindInfo[2])
keybindSlot = keybindCodes[keybindSlot] or keybindSlot
local keybindModifier = tonumber(keybindInfo[3])
keybindModifier = modifiers[keybindModifier] or keybindModifier
local mod = ""
if (keybindModifier) then
mod = " (while " .. keybindModifier .. ")"
end
table.insert(out, "* " .. keybindLabel .. " - " .. keybindSlot .. mod)
end
end
return p