If you place DepositReagentBank by itself into the BANKFRAME_OPENED event, you'll get this error...

I know *sigh* that's what I was going to have to write myself something for -- it just got annoying having BugSack scream FATALITY! every time I opened the bank.

Originally Posted by CobraA1

Nope, delaying the call, even for several seconds, doesn't work. Apparently DepositReagentBank does some extra stuff needs to be done. So the code stays as-is for now, although more elegant solutions would certainly be appreciated if anybody has any ideas.

The reason I asked is b/c the construction you have doesn't prevent multiple calls (which is what I assumed it did when I glanced at it) it just gates the first of multiple (on the first open, it seems to be called once but is called multiple times as you move around the bank/tabs/etc), so I had wondered why a simplified version wasn't preferable. e.g.,

Code:

if not BankFrameItemButton_Update_ORI then -- Copy the function and re-write it
BankFrameItemButton_Update_ORI = BankFrameItemButton_Update
BankFrameItemButton_Update = function(button)
BankFrameItemButton_Update_ORI(button)
end
end
DepositReagentBank()
Print("Reagents done been chucked in the bank -- unless you didn't buy it then ignore this message")

I've had no errors or odd behavior while running it in this form (so far).

DepositReagentBank() also seems kinda blind. An error does get thrown if you don't have it but not by the DepositReagentBank() function or any other I can find.

Nope, delaying the call, even for several seconds, doesn't work. Apparently DepositReagentBank does some extra stuff needs to be done. So the code stays as-is for now, although more elegant solutions would certainly be appreciated if anybody has any ideas.

Thanks for this, I was just thinking I had to write myself something for this.

I can't help but ask though, what the 'BankFrameItemButton_Update_PASS' business is all about. It's only TRUE for the first round in the update storm so it skips using the _OLD button only the first time. Simplifying the code ( to just always feed _OLD a context ) doesn't seem to produce any errors (at least with the testing I've done, using chars with and without the reagent slot). I gather I'm missing something esoteric (or bloody obvious)

If you place DepositReagentBank by itself into the BANKFRAME_OPENED event, you'll get this error:

Avoiding that error is really what the code is all about . . . and why, I assume, such an addon wasn't created before.

The whole purpose of the whole mess is really to temporarily bypass BankFrameItemButton_Update the first time it gets called, as DepositReagentBank apparently creates an event PLAYERREAGENTBANKSLOTS_CHANGED, which immediately calls BankFrameItemButton_Update with an invalid parameter.

I assume that this is due to something not being initialized yet, because subsequent calls to BankFrameItemButton_Update are successful and do not create the error message. Therefore, yes I do only override it once, that is intentional.

This isn't a problem for the player because it's impossible to open the bank, switch to the Reagent Bank Tab, and click the "Deposit All Reagents" button during the exact same frame that BANKFRAME_OPENED is fired. But when I automate it, I have to try to avoid creating that error message.

Now that I think about it, I could try delaying calling DepositReagentBank until a few frames in the future, rather than calling it as soon as BANKFRAME_OPENED is fired. That would be a bit more elegant and might still work, perhaps.

Thanks for this, I was just thinking I had to write myself something for this.

I can't help but ask though, what the 'BankFrameItemButton_Update_PASS' business is all about. It's only TRUE for the first round in the update storm so it skips using the _OLD button only the first time. Simplifying the code ( to just always feed _OLD a context ) doesn't seem to produce any errors (at least with the testing I've done, using chars with and without the reagent slot). I gather I'm missing something esoteric (or bloody obvious)

Support AddOn Development!

You have just downloaded by the author . If you like this AddOn why not consider supporting the author? This author has set up a donation account. Donations ensure that authors can continue to develop useful tools for everyone.