Thread Tools Display Modes
04/09/14, 02:04 AM   #1
Brack
Join Date: Apr 2014
Posts: 5
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.
  Reply With Quote
04/09/14, 05:09 AM   #2
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
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.
  Reply With Quote
04/09/14, 05:14 AM   #3
Wukar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 27
Or
  • TryBankItem(inventorySlot)
  • TryPlaceInventoryItemInEmptySlot(targetBag)
along with PLAYER_INVENTORY:IsBanking()
  Reply With Quote
04/09/14, 06:51 AM   #4
beeradg
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 16
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...
  Reply With Quote
04/09/14, 07:05 AM   #5
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Originally Posted by beeradg View Post
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.
  Reply With Quote
04/09/14, 11:10 AM   #6
Brack
Join Date: Apr 2014
Posts: 5
Thanks everyone for the replies. I'm sure one of these suggestions will work.
  Reply With Quote
04/09/14, 12:02 PM   #7
Brack
Join Date: Apr 2014
Posts: 5
Originally Posted by Wukar View Post
  • TryBankItem(inventorySlot)
  • TryPlaceInventoryItemInEmptySlot(targetBag)
Neither of these functions (or variations) seem to exist.

Originally Posted by Xrystal View Post
PlaceInInventory protected (integer bagId, integer slotIndex)
PickupInventoryItem protected (integer bagId, integer slotIndex, integer count)
Originally Posted by beeradg View Post
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.

Last edited by Brack : 04/09/14 at 12:32 PM.
  Reply With Quote
04/09/14, 12:22 PM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Originally Posted by Xrystal View Post
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.
  Reply With Quote
04/09/14, 12:29 PM   #9
Brack
Join Date: Apr 2014
Posts: 5
I see. That makes sense. So the protected functions can be called, they just have to or should be called using CallSecureProtected()?
  Reply With Quote
04/09/14, 12:41 PM   #10
ins
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 76
Protected might be restricted from being use while in Combat, for example.
  Reply With Quote
04/09/14, 12:44 PM   #11
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
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.
  Reply With Quote
04/09/14, 06:16 PM   #12
beeradg
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 16
Originally Posted by Brack View Post
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
  Reply With Quote
04/09/14, 11:25 PM   #13
Brack
Join Date: Apr 2014
Posts: 5
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.
  Reply With Quote
04/10/14, 01:25 AM   #14
beeradg
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 16
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
  Reply With Quote
04/12/14, 03:36 PM   #15
TheBelgarion
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 13
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
  Reply With Quote
04/12/14, 10:29 PM   #16
Lyrael
Join Date: Apr 2014
Posts: 2
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?
  Reply With Quote
04/13/14, 06:05 PM   #17
beeradg
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 16
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....
  Reply With Quote
04/13/14, 06:07 PM   #18
beeradg
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 16
Originally Posted by TheBelgarion View Post
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.
  Reply With Quote
04/21/14, 06:13 PM   #19
TheBelgarion
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 13
yes calling the moveItem function now with 200ms delay between each call and that works ...
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Add/Remove Items To/From Player Bank?

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