Page 1 of 1

Take maid pot from a bank function

Posted: Mon Jul 04, 2011 9:55 am
by S1y
Hie
Im trying to work out the right function to pick up the item from a bank - so far im using :

Code: Select all

sendMacro("DrawBankItem("..bank_item..")");yrest(500);
and it would work well if not the fact that if there is a same item ( lucky target pot etc) in my inventory it will take item from inventory and add it to the one in bank storage. It works fine otherwise.

Would appreciate a helping hand ;)

Re: Take maid pot from a bank function

Posted: Mon Jul 04, 2011 11:41 am
by wizzyslo
Try with this:

Code: Select all

	sendMacro("PickupBankItem(x);")	
x = slot number in bank 1, 2, 3, 4,...

Code: Select all

	item:moveTo("bag1")
can use bag1, bag2 ,bag3,...

or

Code: Select all

sendMacro("PickupBagItem(x)") 
Works on both way (pick up, put down).

Re: Take maid pot from a bank function

Posted: Tue Jul 05, 2011 1:09 am
by rock5
wizzyslo wrote:

Code: Select all

	item:moveTo("bag1")
can use bag1, bag2 ,bag3,...
Or 'bags', to put it into any bag.

Re: Take maid pot from a bank function

Posted: Tue Jul 05, 2011 6:06 am
by S1y
Thanks a lot for that i will test it shortly and will post results :)

Re: Take maid pot from a bank function

Posted: Thu Jul 07, 2011 3:58 pm
by S1y
HI again,
did some testing recently and have to admit that i still didnt get it right, after picking up an item - its attached to a cursor, and to put it in inventory bag i tried :

Code: Select all

 item:moveTo("bag1")
and it doesnt seem to work - when using "bag1" i got red error message in the middle of the screen : CANNOT ACCESS, THIS BAKCPACK SLOTT IS STILL LOCKED . While using "bags" as a argument the item is picked up from the bank slot and put back in the bank storage 1 slot.
see pic.

Code: Select all

sendMacro("PickupBagItem(x)")
This one is semi working - added 60 to the slot number where and managed to put it in my backpack - but since i wanted them to stack on top of the new ones. Trouble is that i cant find a function that will tell me the slot number if an item by its itemID.

Thanks again for helping out.

Re: Take maid pot from a bank function

Posted: Thu Jul 07, 2011 8:34 pm
by lisa
My guess is you get the "CANNOT ACCESS, THIS BAKCPACK SLOTT IS STILL LOCKED " because it isn't trying to put the item in bag1 like you want, it is trying to put in abag you don't have rented.

There is an interesting situation where the slots in bag 1 are refered to as 1-30 but at the same time a different part of bot refers to them as 61-90.

So if it is saying slot 83 and tries to use that number in the code that uses 1-30 then it will try to put it in another bag and obviously not work the way you want.

To move items you can just right click them while in bank, it will either move to your bag or will make the items stack together in bank if it is a total less then 1 stack, otherwise it just does silly things. Maybe you can use that you your advantage. Somehow lol

Re: Take maid pot from a bank function

Posted: Fri Jul 08, 2011 12:56 am
by rock5
You are not understanding how moveTo works. item:moveTo("bag1") moves 'item' to bag1, not the item you are holding with your mouse. moveTo deals with items in your inventory. Because you are taking an item from your bank you need to use the "PickUp" functions, as you know.

To pickup from the bank

Code: Select all

RoMScript("PickupBankItem("..x..")") -- x is the bank slot number
How you are going to know which bank slot to pick up, I'm not sure.

Then you have to decide where to place the item. If you want to stack it you need to find a similar item.

Code: Select all

toslot = inventory:findItem("Itemname")
if toslot then
    RoMScript("PickupBagItem("..toslot.BagId..")")
end
Then if you have any left over you'll still be holding them in your cursor so you look for an empty slot to put them

Code: Select all

if CursorHasItem() then
    toslot = inventory:findItem(0)
    if toslot then
        RoMScript("PickupBagItem("..toslot.BagId..")")
    end
end
Hm... I'm tempted to write a userfunction for dealing with the bank.

Re: Take maid pot from a bank function

Posted: Fri Jul 08, 2011 3:59 pm
by S1y
Thanks for a quick reply guys.
You are not understanding how moveTo works. item:moveTo("bag1") moves 'item' to bag1, not the item you are holding with your mouse. moveTo deals with items in your inventory. Because you are taking an item from your bank you need to use the "PickUp" functions, as you know.
Yes well basicly that was the reason why i turned to you guys for help - couldnt work out the function to do that work ;) but thanks to your hints i went on the right track.
That "Pickup" function wasnt so easy to work out either ;) took me a while to find out that it needs a second argument ( as where is should look for item ) as it was keep trying to find those pots in the bank slots / finding free slots not in the bag ( item shop bag ) ;)
How you are going to know which bank slot to pick up, I'm not sure.
I have reserved 5 first slots in the bank just for pot swapping and i use the code below to to put it there:

Code: Select all

bank_table = {};
		player:target_NPC("Housekeeper");
		sendMacro("SpeakFrame_ListDialogOption(1, 4)"); yrest(1500); -- opening the bank box
		if( inventory:itemTotalCount(207200) > 0 ) then  -- Unbridled Enthusiasm
			inventory:useItem(207200)
			inventory:update()
			yrest(750)
			table.insert(bank_table,"Potion: Unbridled Enthusiasm")
		end
		if( inventory:itemTotalCount(207202) > 0 ) then -- Clear Thought
			inventory:useItem(207202)
			yrest(1000)
			inventory:update()
			yrest(750)
			table.insert(bank_table,"Potion: Clear Thought")
		end
		if( inventory:itemTotalCount(207203) > 0 ) then  -- Turn of Luck Powder Dust
			inventory:useItem(207203)
			inventory:update()
			yrest(750)
			table.insert(bank_table,"Potion: Turn of Luck Powder Dust")
		end
		if( inventory:itemTotalCount(207210) > 0 ) then  -- Smoked Bacon with Herbs
			inventory:useItem(207210)
			inventory:update()
			yrest(750)
			table.insert(bank_table,"207210")
		end
		sendMacro("CloseWindows()");
Than thanks to you guys i managed to put together a code to pick up those pots from the bank :

Code: Select all

if (#bank_table ~= 0 ) then
			player:target_NPC("Housekeeper");  -- Pick Up Pots from Bank
			sendMacro("SpeakFrame_ListDialogOption(1, 4)"); yrest(1500); -- opening the bank
			for i,v in ipairs(bank_table) do 		
				sendMacro("PickupBankItem("..i..");") ;yrest(500);
				toslot = inventory:findItem(v,"bag1")
				if toslot then  
				print ("Found same item (",v, ") will try to stack them at slot.");
				RoMScript("PickupBagItem("..toslot.BagId..")")
				else
					toslot = inventory:findItem(0,"bags")
					print ("Cant find any stackable item in backpack - (",v, ") will be placed in first empty slot.")
					RoMScript("PickupBagItem("..toslot.BagId..")")
				end
			end
			sendMacro("CloseWindows()"); -- closing the bank
		else
			printf("No bank items to retrieve\n");
		end
Tried to work out the CursorHasItem() function -but gave up after a while - as i doubt it will ever overstack.
Once again thanks for all help :)