• Visit Rebornbuddy
  • Interacting an object via Dev tab

    Discussion in 'Archives' started by cyberbot, Oct 27, 2014.

    1. cyberbot

      cyberbot Member

      Joined:
      Mar 15, 2014
      Messages:
      220
      Likes Received:
      2
      Trophy Points:
      18
      Do I always have to "await" for a coroutine to finish?

      If so, do I have to make Execute() "async" in the Dev for testing?

      The following code crashes EB (ProcessHookManager is enabled and Map Device is highlighted).

      Code:
      public class RuntimeCode
      {
      	private static readonly ILog Log = Logger.GetLoggerInstanceForType();
      
      	public async void Execute()
      	{
      		using(LokiPoe.AcquireFrame())
      		{
      		      var mapDevice = LokiPoe.ObjectManager.MapDevice;
                            Log.DebugFormat("returned {0}.", mapDevice);
      		      var iwoerr = await Loki.Bot.v3.Coroutines.InteractWith<NetworkObject>(mapDevice);
      		      Log.DebugFormat("returned {0}", iwoerr);
      				
      	    }
      	}
      }
      
       
    2. pushedx

      pushedx Moderator Moderator Buddy Core Dev

      Joined:
      Sep 24, 2013
      Messages:
      4,258
      Likes Received:
      290
      Trophy Points:
      83
      You can't run code like that as-is from the Dev tab, because it's a different model of programming. Coroutines require async code execution, which CodeDOM does not use, so you'll have to do extra work if you want to run coroutines from the Dev tab itself.

      Essentially, look at the use of _coroutine in ExampleBot:
      Code:
      private Coroutine _coroutine;
      ...
      _coroutine = new Coroutine(() => MainCoroutine());
      ...
      _coroutine.Resume();
      ...
      etc..
      
      You'll have to execute coroutine code a similar way, as coroutines require continous ticking, and you need to acquire the frame each tick.

      I'll look into adding in something to make running a coroutine slightly less work, but you still have issues with if you don't exit the coroutine properly, it'll run forever in the background, and you'll need to close the bot and restart it to kill that worker thread.
       

    Share This Page