ipairs refactoring
This commit is contained in:
+3
-3
@@ -97,10 +97,10 @@ end
|
||||
function weighted_median(list)
|
||||
sort(list, function(a,b) return a.value < b.value end)
|
||||
local weight = 0
|
||||
for _, element in ipairs(list) do
|
||||
weight = weight + element.weight
|
||||
for i = 1, getn(list) do
|
||||
weight = weight + list[i].weight
|
||||
if weight >= .5 then
|
||||
return element.value
|
||||
return list[i].value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+2
-1
@@ -73,7 +73,8 @@ function extend_tooltip(tooltip, link, quantity)
|
||||
if aux_tooltip_disenchant_distribution then
|
||||
tooltip:AddLine('Disenchants into:', color.tooltip.disenchant.distribution())
|
||||
sort(distribution, function(a,b) return a.probability > b.probability end)
|
||||
for _, event in ipairs(distribution) do
|
||||
for i = 1, getn(distribution) do
|
||||
local event = distribution[i]
|
||||
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, info.display_name(event.item_id, true) or 'item:' .. event.item_id, event.min_quantity, event.max_quantity), color.tooltip.disenchant.distribution())
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user