• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Quick coroutine in plugin example.

    Discussion in 'Community Developer Forum' started by mastahg, Dec 5, 2014.

    1. Sinbeard

      Sinbeard New Member

      Joined:
      Oct 14, 2019
      Messages:
      14
      Likes Received:
      1
      Trophy Points:
      1
      Alright. I made some adjustments (with a couple things from SideStep) and added a log statement at the top of my task. It still doesn't run when I'm using the FishBot. However, I left it enabled when I ran an orderbot profile and the task runs as expected (at least, spits out my log message). It seems that the FishBot itself prevents it from running. Is that the case?

      Updated code attached.
       

      Attached Files:

    2. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,332
      Likes Received:
      378
      Trophy Points:
      83
      Fishbot is one of the oldest botbase and I forgot that it doesn't have treehooks added. I could add it, but you said you had a version that was working onpulse which should be fine as well.
       
    3. Sinbeard

      Sinbeard New Member

      Joined:
      Oct 14, 2019
      Messages:
      14
      Likes Received:
      1
      Trophy Points:
      1
      Ahh, gotcha. I will do that, then. Thank you! Tbh I suppose I could just make some orderbot profiles to handle all of that for me i guess.

      When I place that same code into the onpulse method, I get some memory write errors because it gets pulsed several times before the yes/no window closes (verified with log messages). What's the best way to slow that down in onpulse so it doesn't get banged around?
       
    4. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,332
      Likes Received:
      378
      Trophy Points:
      83
      You could run your own coroutine in the onpulse

      Code:
                                  if (_coroutine == null || _coroutine.IsFinished)
                                  {
                                      _coroutine = new Coroutine(() => yourasyncfunction);
                                  }
      
                                  try
                                  {
                                      _coroutine.Resume();
                                  }
                                  catch (CoroutineException ex)
                                  {
                                      Logging.WriteException(ex);
                                  }
      
      
      define _coroutine outside of onpulse

      then you can use await/async stuff inside that.
       
    5. Sinbeard

      Sinbeard New Member

      Joined:
      Oct 14, 2019
      Messages:
      14
      Likes Received:
      1
      Trophy Points:
      1
      I finally had some time to implement your suggestion to my little plugin. It works, but it still executes the task about 4 or 5 times and throws a memory exception (I can post a log tomorrow or so) similar to what I mentioned before. I must be doing something wrong, but RB seems like it tries to launch the task each time the plugin is pulsed. I added in another check that I haven't tested yet.

      In any case, thanks for the help so far mastahg
       

    Share This Page