From c086437295621565228972254b69d6c430019854 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sat, 18 Mar 2017 13:58:34 +0100 Subject: [PATCH] deposit bugfix --- tabs/post/core.lua | 2 +- util/persistence.lua | 50 ++++++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/tabs/post/core.lua b/tabs/post/core.lua index 484c1e7..bcfb1f1 100644 --- a/tabs/post/core.lua +++ b/tabs/post/core.lua @@ -326,7 +326,7 @@ function update_item_configuration() stack_count_slider.editbox:SetNumber(stack_count_slider:GetValue()) do - local deposit_factor = UnitFactionGroup'npc' and .25 or .05 + local deposit_factor = UnitFactionGroup'npc' and .05 or .25 local stack_size, stack_count = stack_size_slider:GetValue(), stack_count_slider:GetValue() local amount = floor(selected_item.unit_vendor_price * deposit_factor * (selected_item.max_charges and 1 or stack_size)) * stack_count * UIDropDownMenu_GetSelectedValue(duration_dropdown) / 120 deposit:SetText('Deposit: ' .. money.to_string(amount, nil, nil, nil, color.text.enabled)) diff --git a/util/persistence.lua b/util/persistence.lua index 76d5f00..95ed9c8 100644 --- a/util/persistence.lua +++ b/util/persistence.lua @@ -10,31 +10,35 @@ _G.aux = { account = {}, } -local cache = {account=aux.account} - -function LOAD2() - do - local key = format('%s|%s', GetCVar'realmName', UnitName'player') - aux.player[key] = aux.player[key] or {} - cache.player = aux.player[key] +do + local cache = {} + function LOAD() + cache.account = aux.account + do + local key = format('%s|%s', GetCVar'realmName', UnitName'player') + aux.player[key] = aux.player[key] or {} + cache.player = aux.player[key] + end + do + local key = GetCVar'realmName' + aux.realm[key] = aux.realm[key] or {} + cache.realm = aux.realm[key] + end end - do - local key = format('%s|%s', GetCVar'realmName', UnitFactionGroup'player') - aux.faction[key] = aux.faction[key] or {} - cache.faction = aux.faction[key] + function LOAD2() + do + local key = format('%s|%s', GetCVar'realmName', UnitFactionGroup'player') + aux.faction[key] = aux.faction[key] or {} + cache.faction = aux.faction[key] + end end - do - local key = GetCVar'realmName' - aux.realm[key] = aux.realm[key] or {} - cache.realm = aux.realm[key] - end -end - -for scope in temp-S('player', 'faction', 'realm', 'account') do - local scope = scope - M[scope] = function(k) - cache[scope][k] = cache[scope][k] - return cache[scope][k] + for scope in temp-S('player', 'faction', 'realm', 'account') do + local scope = scope + M[scope] = function(k) + if not cache[scope] then error('Cache not ready', 2) end + cache[scope][k] = cache[scope][k] or {} + return cache[scope][k] + end end end