Thread Tools Display Modes
04/14/23, 08:29 PM   #1
sinnereso
AddOn Author - Click to view addons
Join Date: Oct 2022
Posts: 244
Question updated bank balances

Anyone know of a way to "update" current bank balances data after depositing? Currently I'm having to add previous balance to deposited balance for correct numbers because this returns previous balance before depositing for example:

Code:
amount = GetBankedCurrencyAmount(CURT_TELVAR_STONES) <<<< if this was 100

deposit blah blah blah <<<<<< and deposited 100

currAmount = GetBankedCurrencyAmount(CURT_TELVAR_STONES) <<<< this returns still 100

df(" bank balance: " .. tostring(currAmount)) <<< and displays in chat 100 instead of 200
once you reopen the bank it gets current correct numbers but is there a way to get updated correct data right after depositing in code?

Last edited by sinnereso : 04/14/23 at 09:00 PM.
  Reply With Quote
04/15/23, 01:20 AM   #2
FlatBadger
 
FlatBadger's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2021
Posts: 17
Are you calling this the second time in response to an event? It may just be that you're calling it too early.

There's a few events that could be of interest:
Code:
EVENT_TELVAR_STONE_UPDATE
EVENT_CURRENCY_UPDATE
EVENT_BANKED_CURRENCY_UPDATE
My addon monitors various currency types and I'm not seeing any issues, but they are all event triggered.
  Reply With Quote
04/15/23, 01:47 AM   #3
sinnereso
AddOn Author - Click to view addons
Join Date: Oct 2022
Posts: 244
no event for it... other than openbank which calls the rest of the function but at the end it checks balance then deposits telvar and outputs to chat the sum of balance and deposit becase if i check balance again after its the same as before deposit.

I dont see why this wont work:

Code:
local amount = GetCarriedCurrencyAmount(CURT_TELVAR_STONES)
if (amount > 0) then
	local bankAmount = GetBankedCurrencyAmount(CURT_TELVAR_STONES)
	DepositCurrencyIntoBank(CURT_TELVAR_STONES, amount)
	df("|c6666FF[RidinDirty]|r Deposited |c33CCCC" .. amount .. "|r telvar. " .. " Bank balance: |c33CCCC" .. amount+bankAmount .. "|r")
	****** for example if i did GetBankedCurrencyAmount(CURT_TELVAR_STONES) right here id get back same as previous one before the deposit
end
as you can see i have to add amount+bankAmount for accurate bank balance because if i do a "GetBankedCurrencyAmount(CURT_TELVAR_STONES)" at anytime after without opening bank again its always the previous balance.

Last edited by sinnereso : 04/15/23 at 01:56 AM.
  Reply With Quote
04/15/23, 02:27 AM   #4
FlatBadger
 
FlatBadger's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2021
Posts: 17
What I mean is that after depositing you need to wait for an event to fire before you can retrieve the updated balance.
  Reply With Quote
04/15/23, 04:50 AM   #5
sinnereso
AddOn Author - Click to view addons
Join Date: Oct 2022
Posts: 244
Ahh.. Well ive managed to get it working with an event and a variable switch because i want the bank balances to display when opeing the bank but also when depositing and withdrawing so the switch disables the bank open display during my auto telvar deposit function and only allowed the currency event to display it. Seems to be working well so far in testing.

MORE IMPORTANTLY MAYBE I also noticed the new "live" api notes are incorrect.

Code:
* EVENT_BANKED_CURRENCY_UPDATE (*[CurrencyType|#CurrencyType]* _currency_, *integer* _newValue_, *integer* _oldValue_)

the variable positions are off.. it is actually(possibly old value but wildly incorrect, currency, newvalue). I sense a shift in the force here and it may not be functioning properly. As an example the "possibly old value" was returing a number in the 135,000 range when moving 10000 telvar in and out of bank when i have 160000. There was a missing 15000ish from what it was returning. The oldvalue could only have been 150000ish and 160000ish

maybe the ZOS super powers will read this and get it fixed up if something is wrong with it

Last edited by sinnereso : 04/15/23 at 05:06 AM.
  Reply With Quote
04/15/23, 05:04 AM   #6
FlatBadger
 
FlatBadger's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2021
Posts: 17
The first parameter for all events is actually the event id, so that documentation is slightly misleading if you don't realise that. In this case, it's actually:

Code:
EVENT_BANKED_CURRENCY_UPDATE (*integer* _eventId_, *[CurrencyType|#CurrencyType]* _currency_, *integer* _newValue_, *integer* _oldValue_)
  Reply With Quote
04/15/23, 05:10 AM   #7
sinnereso
AddOn Author - Click to view addons
Join Date: Oct 2022
Posts: 244
oh! damn! I thought i discovered something useful there haha. thankyou ill get the _ in my code for that.
  Reply With Quote
04/15/23, 08:37 PM   #8
sinnereso
AddOn Author - Click to view addons
Join Date: Oct 2022
Posts: 244
Ive managed to re-write it and eliminate the "EVENT_BANKED_CURRENCY_UPDATE" by passing variables from one function to the other which I should have thought of in the 1st place. Im trying to keep it as light weight as possible and I only needed it on bank open and telvar auto deposit so this works better for me.

Last edited by sinnereso : 04/16/23 at 01:23 AM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » updated bank balances

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off