tbc loop change part 5

This commit is contained in:
Manuel Simon Hirsig
2017-06-02 20:19:32 +02:00
parent 0fe79adf99
commit d9da99b537
6 changed files with 41 additions and 25 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ do
end
function LOAD2()
characters = realm_data'characters'
for k, v in characters do
for k, v in pairs(characters) do
if GetTime() > v + 60 * 60 * 24 * 30 then
characters[k] = nil
end
+1 -1
View File
@@ -37,7 +37,7 @@ local WEAPON = S(
function M.value(slot, quality, level)
local expectation
for _, event in distribution(slot, quality, level) do
for _, event in pairs(distribution(slot, quality, level)) do
local value = history.value(event.item_id .. ':' .. 0)
if not value then
return
+5 -5
View File
@@ -65,12 +65,12 @@ function M.value(item_key)
item_record = read_record(item_key)
if getn(item_record.data_points) > 0 then
local total_weight, weighted_values = 0, temp-T
for _, data_point in item_record.data_points do
for _, data_point in pairs(item_record.data_points) do
local weight = .99 ^ round((item_record.data_points[1].time - data_point.time) / (60 * 60 * 24))
total_weight = total_weight + weight
tinsert(weighted_values, O('value', data_point.value, 'weight', weight))
end
for _, weighted_value in weighted_values do
for _, weighted_value in pairs(weighted_values) do
weighted_value.weight = weighted_value.weight / total_weight
end
value = weighted_median(weighted_values)
@@ -89,10 +89,10 @@ end
function weighted_median(list)
sort(list, function(a,b) return a.value < b.value end)
local weight = 0
for i = 1, getn(list) do
weight = weight + list[i].weight
for _, v in ipairs(list) do
weight = weight + v.weight
if weight >= .5 then
return list[i].value
return v.value
end
end
end
+3 -3
View File
@@ -27,14 +27,14 @@ do
function M.abort(scan_id)
local aborted = T
for type, state in scan_states do
for type, state in pairs(scan_states) do
if not scan_id or state.id == scan_id then
kill_thread(state.id)
scan_states[type] = nil
tinsert(aborted, state)
end
end
for _, state in aborted do
for _, state in pairs(aborted) do
do (state.params.on_abort or nop)() end
end
end
@@ -50,7 +50,7 @@ do
end
function get_state()
for _, state in scan_states do
for _, state in pairs(scan_states) do
if state.id == thread_id then
return state
end
+2 -3
View File
@@ -18,7 +18,7 @@ function LOAD()
settings = character_data('tooltip', {value=true})
do
local inside_hook = false
for name, f in game_tooltip_hooks do
for name, f in pairs(game_tooltip_hooks) do
local name, f = name, f
hook(name, GameTooltip, vararg-function(arg)
inside_hook = true
@@ -61,8 +61,7 @@ function M.extend_tooltip(tooltip, link, quantity)
if settings.disenchant_distribution then
tooltip:AddLine('Disenchants into:', color.tooltip.disenchant.distribution())
sort(distribution, function(a,b) return a.probability > b.probability end)
for i = 1, getn(distribution) do
local event = distribution[i]
for _, event in ipairs(distribution) do
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