Module:ItemData: Difference between revisionsGive feedback
TheMilkMan (talk | contribs) Adding ActiveBonusLifesteal to percentages |
created get_property_upgrade |
||
| Line 368: | Line 368: | ||
end | end | ||
-- {{#invoke:ItemData|get_property_upgrade|ITEM_NAME|PROPERTY}} -- | |||
p.get_property_upgrade = function(frame) | |||
local item_name = frame.args[1] | |||
local property = frame.args[2] | |||
local item = get_json_item(item_name) | |||
if item == nil then | |||
return "<span style=\"color:red;\">Item Not Found.</span>" | |||
end | |||
local upgrades = item["PropertyUpgrades"] | |||
if upgrades == nil then return nil end | |||
local prop_upgrades = upgrades[property] | |||
if prop_upgrades == nil then return nil end | |||
-- Convert upgrade values to strings | |||
local values = {} | |||
for _, v in ipairs(prop_upgrades) do | |||
table.insert(values, tostring(v)) | |||
end | |||
local result = table.concat(values, ", ") | |||
-- Append % if this property is percentage-based | |||
if percentage_properties[property] == true then | |||
return result .. "%" | |||
else | |||
return result | |||
end | |||
end | |||
return p | return p | ||