What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Coroutines.WithdrawItemsCoroutine

cyberbot

Member
Joined
Mar 15, 2014
Messages
220
Reaction score
2
If I use "Coroutines.WithdrawItemsCoroutine", is it true that the routine always starts from the first tab?

If there is a way to start from a particular tab, can you tell me how?
 
If I use "Coroutines.WithdrawItemsCoroutine", is it true that the routine always starts from the first tab?

If there is a way to start from a particular tab, can you tell me how?
Hey. Um so the coroutine goes like this

Code:
Coroutines.WithdrawItemsCoroutine(ShouldWithdrawFromTab, ShouldWithdrawItem, ContinueWithdrawing);

so..
you can use
Code:
var wierr =
                    await
                        Coroutines.WithdrawItemsCoroutine(ShouldWithdrawFromTab, ShouldWithdrawItem, ContinueWithdrawing);
                if (wierr != Coroutines.WithdrawItemsCoroutineError.None)
                {
                    Log.ErrorFormat("[WithDrawItemsTask] WithdrawItemsCoroutine returned {0}.", wierr);
                    BotManager.Stop();
                }
                else
                {
                    Log.InfoFormat(
                        "[WithDrawItemsTask] Withdrawing has completed.");
                    BotManager.Stop();
                }
Code:
private bool ShouldWithdrawItem(Item item, out int count, object user)
            {
                   ////Your code here
                   return true
            }

return true if you want item withdrawn for the function

Code:
private bool ShouldWithdrawFromTab(InventoryTab tab, object user)
            {
                return true;
            }

Specifies the tab, again return true if it's the tab you want.

Code:
private bool ContinueWithdrawing(object user)
            {
                if (LokiPoe.InGameState.InventoryPanel.MainInventory.AvailableInventorySquares == 0)
                {
                    return false;
                }
                    
                return true;
            }
and this one is so if you run out of space return false, else keep withdrawing items that need to be withdrawn.

Hope that helps, Pushedx, might need to give more info, but that's what I've learned.

Edit oh and a bonus

Code:
Loki.Bot.Logic.Bots.BasicGrindBot.StashTask.StashTask(Loki.Bot.v3.Coroutines.NeedsToStashDelegate, Loki.Bot.v3.Coroutines.StashingCompleteDelegate, Loki.Bot.v3.Coroutines.StashItemsDelegate, Loki.Bot.v3.Coroutines.BestStashTabForItem, [object])
 
Last edited:
Dark, I believe (and tried) what you quoted starts from the first tab as-is, and "InventoryTab tab" is implicitly passed to the "ShouldWithdrawFromTab" function, but not specified.
 
If I use "Coroutines.WithdrawItemsCoroutine", is it true that the routine always starts from the first tab?

If there is a way to start from a particular tab, can you tell me how?

Yes, the coroutine is coded to start from the first tab. Otherwise, it'd miss being able to withdraw items from other stash operations moving the currently selected tab page when it starts.

You'd have to code your own withdraw coroutine if you wanted a different behavior. All the coroutine does really is go to stash and open it, then goes to the first tab, and calls the user functions for each tab/inventory. Everything is done from using LokiPoe.InGameState.StashPanel, and it's not much code overall. It just uses CurrentTabInventoryTab to get the current tab, which is paseed to the user delegate for checking if a tab should be withdrawn from, then iterates items from CurrentTabInventory, calling the user delegate to see if an item should be withdrawn. You can use FastMove to move items from the stash to the main inventory, but you'll want to be sure it'll fit by checking LokiPoe.InGameState.InventoryPanel.MainInventory.CanFitItem.
 
Can you say more how to use the FastMove function?

I tried it in the Dev tab with my stash open:

Code:
public class RuntimeCode
{
	private static readonly ILog Log = Logger.GetLoggerInstanceForType();

	public void Execute()
	{
		using(LokiPoe.AcquireFrame())
		{
                    List<Item> itemlist=Loki.Game.LokiPoe.InGameState.StashPanel.CurrentTabItems;
		    foreach(var item in itemlist)
                         if (item.Name=="Raise Spectre")
                              Loki.Game.LokiPoe.InGameState.StashPanel.FastMove(item);
	    }
	}

}

Nothing happened. Do I have to move my cursor to the object first?
 
Can you say more how to use the FastMove function?

I tried it in the Dev tab with my stash open:

Code:
public class RuntimeCode
{
	private static readonly ILog Log = Logger.GetLoggerInstanceForType();

	public void Execute()
	{
		using(LokiPoe.AcquireFrame())
		{
                    List<Item> itemlist=Loki.Game.LokiPoe.InGameState.StashPanel.CurrentTabItems;
		    foreach(var item in itemlist)
                         if (item.Name=="Raise Spectre")
                              Loki.Game.LokiPoe.InGameState.StashPanel.FastMove(item);
	    }
	}

}

Nothing happened. Do I have to move my cursor to the object first?
Hey dude, did you make sure that
Code:
Loki.Game.LokiPoe.InGameState.IsStashPanelOpen
and
Code:
Loki.Game.LokiPoe.InGameState.IsInventoryPanelOpen
Prior to running the code?
Ops, I think bot might need to run, if that's the case use ScriptedBot.
 
Last edited:
You always want to store the result of the API function and log/process it to know what is going on. Change that to:
Code:
if (item.Name=="Raise Spectre")
{
   var res = Loki.Game.LokiPoe.InGameState.StashPanel.FastMove(item);
   Log.InfoFormat("FastMove returned {0}", res);
}
to understand why it did nothing.

Once you've done that, you can switch to the client, and press alt + shift + e to enable the ProcessHookManager, and then alt + shift + d to disable it. I thought I had that info in the Dev tab guide, but I'll get it added now, as I see I've only mentioned it in a few threads in response to issues with it.

Alternatively, you'll want to enable/disable it in the code itself by using the API function before calling any functions that perform input actions.
 
You always want to store the result of the API function and log/process it to know what is going on. Change that to:
Code:
if (item.Name=="Raise Spectre")
{
   var res = Loki.Game.LokiPoe.InGameState.StashPanel.FastMove(item);
   Log.InfoFormat("FastMove returned {0}", res);
}
to understand why it did nothing.

Once you've done that, you can switch to the client, and press alt + shift + e to enable the ProcessHookManager, and then alt + shift + d to disable it. I thought I had that info in the Dev tab guide, but I'll get it added now, as I see I've only mentioned it in a few threads in response to issues with it.

Alternatively, you'll want to enable/disable it in the code itself by using the API function before calling any functions that perform input actions.

Thanks!!
 
Back
Top