Home
Random
Log in
Settings
About the Deadlock Wiki
Search
Editing
Module:Abilities/utils
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local commonutils = require "Module:Utilities" local lang = require"Module:Lang" local data = mw.loadJsonData("Data:AbilityCards.json") -- returns the table of a specific item' function p.get_ability_card_data(hero_key, ability_num) if(hero_key == nil) then return nil end return data[hero_key][tonumber(ability_num)] end function p.get_hero_key(hero_name) for i, hero in pairs(data) do if hero["Name"] == hero_name then return i end end return nil end -- Add prefix and postfix labels to a value. Eg. "32" -> "32s" function p.format_value_with_prepost(key, value, frame, exclude_plus) if (value == nil) then return nil end local prefix = lang.get_string(string.format("%s_prefix",key)) local postfix = lang.get_string(string.format("%s_postfix",key)) -- Default pre/post fix to empty string, as they may not exist if (prefix == nil) then prefix = '' end if (postfix == nil) then postfix = '' end -- If string ends with 'm', then set the postfix to 'm' and remove it if commonutils.string_endswith(tostring(value), 'm') then value = tonumber(value:sub(1, -2)) postfix = 'm' end if (prefix == '{s:sign}') then if value < 0 then prefix = '-' else prefix = '+' end -- if no prefix on positive value, add a '+' else if value > 0 then prefix = '+' end end -- some use cases don't require the '+' symbol prefix if exclude_plus == true and prefix == '+' then prefix = '' end value_and_uom = frame:expandTemplate{ title = 'Template:ValueAndUom', args = { prefix..value, postfix, uom_style = 'font-size: 12px;' } } return value_and_uom end return p
Summary:
Please note that all contributions to Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Deadlock:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Templates used on this page:
Module:Abilities/doc/submodules
(
edit
)
Module:Abilities/utils/doc
(
edit
)