1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Request "beginLoop" type method

Discussion in 'Client & Site Suggestions' started by Aydex, May 7, 2017.

  1. Aydex

    Joined:
    Dec 28, 2013
    Messages:
    190
    Likes Received:
    31
    There's quite a few things developers would probably want to do each loop that really wouldn't fit into a task/tree node. Especially when developing base frameworks it would be very useful and clean to run generic logic (ensure roofs are disabled, run is enabled if above a certain threshold, etc) before onLoop runs. Internally the first line of onLoop would literally just change to a call to "beginLoop".

    Both Task/Tree bots literally extend from LoopingBot. We should be able to utilize this.

    Or just simply allow us to override onLoop and assume developers will be smart enough to call the super method.
     
    #1 Aydex, May 7, 2017
    Last edited: May 8, 2017
  2. SuperBotter

    SuperBotter Super Bot Author

    Joined:
    Jun 24, 2016
    Messages:
    151
    Likes Received:
    52
    So you want something to run at the start of the bot, but not in every loop? You mean like onStart()?
     
    Jux7apose likes this.
  3. Jux7apose

    Joined:
    Mar 28, 2017
    Messages:
    286
    Likes Received:
    58
    ^ onStart()
     
  4. Aydex

    Joined:
    Dec 28, 2013
    Messages:
    190
    Likes Received:
    31
     
  5. Jux7apose

    Joined:
    Mar 28, 2017
    Messages:
    286
    Likes Received:
    58
    Well then, why not just make it your starting branch. You say you can't, but I'd figure you can.

    Check to see your arguements you mention above (run & roofs)

    yes? -> begin running bot
    no? -> well, enable roofs and run, or jusut stop the bot

    Personally, I don't see the problem, then again, I have yet to dev a bot
     
  6. Baddest Man on Earth

    Joined:
    Nov 26, 2014
    Messages:
    616
    Likes Received:
    246
    Couldn't you use a TreeTask as your root and flag it as a leaf?
     
  7. Aydex

    Joined:
    Dec 28, 2013
    Messages:
    190
    Likes Received:
    31
    This goes against the entire point of the Tree/Task framework. Having an "entry" level branch you use in all your bots that executes some generic code (which would have to be done in the onValidate method mind you, I don't think I have to explain how terrible this is) would always return the same value to enter your bots main branch. This is literally an overcomplicated "beginLoop" method.

    Granted you "could" use onValidate as a way to check your generic config is set properly and if not execute a specific leaf (and if so continue on with your bots core logic) but there are certain things that a developer may need to do that don't require checks and should be executed every loop. This runs back into the issue I stated above where you're executing code in onValidate.

    See my reply above.
     
  8. Snufalufugus

    Joined:
    Aug 23, 2015
    Messages:
    1,961
    Likes Received:
    757
    You can just write what you need and put it at the beginning of each leaf. I don't see many, if any use cases for this though tbh. Stuff like run energy is already managed automatically behind the scenes, and most other things should/could just be their own leafs.
     
  9. Aydex

    Joined:
    Dec 28, 2013
    Messages:
    190
    Likes Received:
    31
    You could but you'd end up duplicating code all over the place. Again, this is mainly for developing base frameworks (which I'm surprised it seems most people don't do) instead of extending RuneMates base TreeBot for every bot you write.

    Run energy is only managed if you 1) pass the traversal option and 2) actually use step. You'll never call these methods (and therefore never have the bot toggle run) if you're in an enclosed place such as the blast furnace.
     

Share This Page

Loading...