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

Interacting an object via Dev tab

cyberbot

Member
Joined
Mar 15, 2014
Messages
220
Reaction score
2
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);
				
	    }
	}
}
 
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.
 
Back
Top