Module:ItemData: Difference between revisionsGive feedback
TheMilkMan (talk | contribs) Adding BuffBulletResist and BuffTechResist to percentages |
added get_prop_meta |
||
| Line 417: | Line 417: | ||
return result | return result | ||
end | end | ||
end | |||
-- Helping function for [[Module:Enhanced]] | |||
function p.get_prop_meta(item_name, property) | |||
local item = get_json_item(item_name) | |||
if not item then return nil end | |||
local raw = item[property] | |||
if raw == nil then return nil end | |||
local meta = { | |||
unit = nil, -- "%", "m", "s" or nil | |||
scale = nil -- { type = "Ss"/"Boon", value = number } or nil | |||
} | |||
if percentage_properties[property] then | |||
meta.unit = "%" | |||
end | |||
if type(raw) == "table" | |||
and raw.Scale | |||
and raw.Scale.Value | |||
and raw.Scale.Type | |||
then | |||
local scale_val = tonumber(raw.Scale.Value) | |||
if scale_val and scale_val ~= 0 then | |||
meta.scale = { | |||
type = raw.Scale.Type == "power_increase" and "Boon" or "Ss", | |||
value = util_module.round_to_sig_fig(scale_val, 2) | |||
} | |||
end | |||
end | |||
return meta | |||
end | end | ||
return p | return p | ||