ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Add/Remove Items To/From Player Bank? (https://www.esoui.com/forums/showthread.php?t=718)

Brack 04/09/14 02:04 AM

Add/Remove Items To/From Player Bank?
 
Hey Guys,

I've tried to find the function for this but I cant seem to. I want to add and remove items from the player's bank when at the bank screen. I see these two functions...
  • TransferToGuildBank(integer sourceBag, integer sourceSlot)
  • TransferFromGuildBank(integer slotId)
... but none for the player bank. Is this possible? Any ideas?

Thanks.

Xrystal 04/09/14 05:09 AM

PlaceInInventory protected (integer bagId, integer slotIndex)
PickupInventoryItem protected (integer bagId, integer slotIndex, integer count)

bagId would be 2 for the player bank, slotIndex the item you want taken out ( not necessarily the one you see at that position on screen though.

Wukar 04/09/14 05:14 AM

Or
  • TryBankItem(inventorySlot)
  • TryPlaceInventoryItemInEmptySlot(targetBag)
along with PLAYER_INVENTORY:IsBanking()

beeradg 04/09/14 06:51 AM

None of those worked for me...
 
I submitted an addon that uses the "protected" functions - and works.

You have to do something like:
CallSecureProtected("PickupInventoryItem", fromBag, fromSlot, quantity)

Here's a git repo https://github.com/bradgearon/eso-stuff

Stuff.lua line 11 and 14 are the important chunks...

Xrystal 04/09/14 07:05 AM

Quote:

Originally Posted by beeradg (Post 3483)
I submitted an addon that uses the "protected" functions - and works.

You have to do something like:
CallSecureProtected("PickupInventoryItem", fromBag, fromSlot, quantity)

Here's a git repo https://github.com/bradgearon/eso-stuff

Stuff.lua line 11 and 14 are the important chunks...

Interesting.I'm surprised that was allowed. Maybe one missed from their API clean out.

Brack 04/09/14 11:10 AM

Thanks everyone for the replies. I'm sure one of these suggestions will work. :)

Brack 04/09/14 12:02 PM

Quote:

Originally Posted by Wukar (Post 3466)
  • TryBankItem(inventorySlot)
  • TryPlaceInventoryItemInEmptySlot(targetBag)

Neither of these functions (or variations) seem to exist.

Quote:

Originally Posted by Xrystal (Post 3465)
PlaceInInventory protected (integer bagId, integer slotIndex)
PickupInventoryItem protected (integer bagId, integer slotIndex, integer count)

Quote:

Originally Posted by beeradg (Post 3483)
You have to do something like:
CallSecureProtected("PickupInventoryItem", fromBag, fromSlot, quantity)

Okay so CallSecureProtected("PickupInventoryItem", fromBag, fromSlot, quantity) works, as an item in my inventory is placed in my mouse cursor, however that isn't the desired outcome. I want items to be moved to the bank without player interaction (or at least not more than one button click).

I then tried CallSecureProtected("PlaceInInventory", fromBag, fromSlot) but this didn't seem to be able to move banked items into the inventory.

So it seems I'm still stuck. Are we even supposed to be able to use protected functions? I thought the purpose of those was to not allow modders access to those. Seems pretty silly that moving items around in a player's inventory/bank space would be protected anyway.


Edit: Actually I think I got it working... Here is my code that worked (for testing):
Code:

CallSecureProtected("PickupInventoryItem", 1, 1, 1)
BankFirstEmpty = FindFirstEmptySlotInBag(2)
CallSecureProtected("PlaceInInventory", 2, BankFirstEmpty)

Thanks to everyone again for the help.

Seerah 04/09/14 12:22 PM

Quote:

Originally Posted by Xrystal (Post 3485)
Interesting.I'm surprised that was allowed. Maybe one missed from their API clean out.

Well, protected =/= private. The CallSecureProtected() function sounds like their version of secure handlers in WoW.

Brack 04/09/14 12:29 PM

I see. That makes sense. So the protected functions can be called, they just have to or should be called using CallSecureProtected()?

ins 04/09/14 12:41 PM

Protected might be restricted from being use while in Combat, for example.

Xrystal 04/09/14 12:44 PM

d'oh. Sometimes I am so brain dead.

Yes, if they are along the lines of WoW's secure handlers there is a distinct possibility you won't be able to do certain stuff during combat.

beeradg 04/09/14 06:16 PM

Quote:

Originally Posted by Brack (Post 3535)
Neither of these functions (or variations) seem to exist.





Okay so CallSecureProtected("PickupInventoryItem", fromBag, fromSlot, quantity) works, as an item in my inventory is placed in my mouse cursor, however that isn't the desired outcome. I want items to be moved to the bank without player interaction (or at least not more than one button click).

I then tried CallSecureProtected("PlaceInInventory", fromBag, fromSlot) but this didn't seem to be able to move banked items into the inventory.

So it seems I'm still stuck. Are we even supposed to be able to use protected functions? I thought the purpose of those was to not allow modders access to those. Seems pretty silly that moving items around in a player's inventory/bank space would be protected anyway.


Edit: Actually I think I got it working... Here is my code that worked (for testing):
Code:

CallSecureProtected("PickupInventoryItem", 1, 1, 1)
BankFirstEmpty = FindFirstEmptySlotInBag(2)
CallSecureProtected("PlaceInInventory", 2, BankFirstEmpty)

Thanks to everyone again for the help.

Glad that worked. From the code in that link I posted: (had the answer all along) :)
Code:

function stackItem(fromBag, fromSlot, toBag, toSlot, quantity, name)
    local result = true
    -- just in case
    ClearCursor()
    -- must call secure protected (pickup the item via cursor)
    result = CallSecureProtected("PickupInventoryItem", fromBag, fromSlot, quantity)
    if (result) then
        -- must call secure protected (drop the item on the cursor)
        result = CallSecureProtected("PlaceInInventory", toBag, toSlot)
    end
    -- clear the cursor to avoid issues
    ClearCursor()
    return result
end


Brack 04/09/14 11:25 PM

Ahh not a bad little function. I'm curious what the name parameter is for since it doesn't seem to be used anywhere within the function.

beeradg 04/10/14 01:25 AM

Name parameter
 
Was fallout from refactoring... At first I was logging in that function and wanted to see the name but later moved things around and my trust for the callsecureprotected thing increased :)

TheBelgarion 04/12/14 03:36 PM

MovingItem
 
Hi,

i moved my item with the functions mentioned above and it works ... but than moving more than one
FindFirstEmptySlotInBag(2) always reports the same position to insert new item, which does not work naturally ... how can I update bag so its finds a new empty SLot?

-- must call secure protected (pickup the item via cursor)
result = CallSecureProtected("PickupInventoryItem", item.bag, item.slot, item.stack)
if (result) then
-- must call secure protected (drop the item on the cursor)
result = CallSecureProtected("PlaceInInventory", toBag, toSlot)
end

Lyrael 04/12/14 10:29 PM

I just wanted to say thanks for this thread which has brought to my attention the CallSecureProtected method.

Where did you find out about it? Is there documentation somewhere which I can read?

beeradg 04/13/14 06:05 PM

I dug...
 
I found out about that from digging, completely. There is no documentation anywhere. Hopefully there will be at some point, but it shows up in the raw dump -- so I simply tried calling it will string functionName and args purely by convention, assumption, and a tiny bit of trial and error. It did take me around 2-4 hours to finally find it though, during which I came very close to giving up (but giving up something like that for me is usually much more difficult that finishing it). thus....

beeradg 04/13/14 06:07 PM

Quote:

Originally Posted by TheBelgarion (Post 4006)
Hi,

i moved my item with the functions mentioned above and it works ... but than moving more than one
FindFirstEmptySlotInBag(2) always reports the same position to insert new item, which does not work naturally ... how can I update bag so its finds a new empty SLot?

-- must call secure protected (pickup the item via cursor)
result = CallSecureProtected("PickupInventoryItem", item.bag, item.slot, item.stack)
if (result) then
-- must call secure protected (drop the item on the cursor)
result = CallSecureProtected("PlaceInInventory", toBag, toSlot)
end

You probably need to implement some time buffering or wait for the update single item inventory event before moving the next item.

TheBelgarion 04/21/14 06:13 PM

yes calling the moveItem function now with 200ms delay between each call and that works ...


All times are GMT -6. The time now is 04:58 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI