Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Buy OSRS Gold

Sell OSRS Gold
Worthy

Node Framework Tutorial [increase efficiency and clarity]

Recommended Posts

Guest

Anyone who's feeling overwhelmed with States and large switch statements should have a go at writing a script using the Node Framework.

Great guide =)

I can't thank you enough! <3

Share this post


Link to post
Share on other sites

Hey I got a few questions and hoping you can answer them for me. I'm pretty curious if you still use this framework within your big scripts. I also noticed when using one node that doesn't get validated there won't be applied a sleep. I first thought that the sleep was placed wrong but later foundout, that normally there will always be a node that get's validated so sleep will get called.

But what happens if you have alot of nodes, let's say 20 and the first 19 won't be executed, so the validate methods will be called but there is no sleep. Won't there be lag if we have that kind of situation?

 

And the last question I have is, what is the better way to handle this:

	@Override
	public boolean validate()
	{
		return playerIsInArea();
	}
	// and have the following part in the execute() if(!Inventory.isFull() && Combat.getHP() > 14 && !Combat.isUnderAttack() && tmpArea.contains(Player.getPosition())){}

OR

	private boolean playerIsInArea()
	{
		return (!Inventory.isFull() && Combat.getHP() > 14 && !Combat.isUnderAttack() && tmpArea.contains(Player.getPosition()));
	}

I would think the first example would be better, because it would only check on the rest of the term's  if the player is in the area.

 

I'm hoping you could answer my questions and help me out.

Edited by Sophisticated

Share this post


Link to post
Share on other sites
7 hours ago, Sophisticated said:

Hey I got a few questions and hoping you can answer them for me. I'm pretty curious if you still use this framework within your big scripts. I also noticed when using one node that doesn't get validated there won't be applied a sleep. I first thought that the sleep was placed wrong but later foundout, that normally there will always be a node that get's validated so sleep will get called.

But what happens if you have alot of nodes, let's say 20 and the first 19 won't be executed, so the validate methods will be called but there is no sleep. Won't there be lag if we have that kind of situation?

 

And the last question I have is, what is the better way to handle this:

	@Override
	public boolean validate()
	{
		return playerIsInArea();
	}
	// and have the following part in the execute() if(!Inventory.isFull() && Combat.getHP() > 14 && !Combat.isUnderAttack() && tmpArea.contains(Player.getPosition())){}

OR

	private boolean playerIsInArea()
	{
		return (!Inventory.isFull() && Combat.getHP() > 14 && !Combat.isUnderAttack() && tmpArea.contains(Player.getPosition()));
	}

I would think the first example would be better, because it would only check on the rest of the term's  if the player is in the area.

 

I'm hoping you could answer my questions and help me out.

Yes I still use this in my large scripts, such as Zulrah. However, the Zulrah script only has 5 nodes. Everything is encapsulated in an object, and things interact at a higher level, thus there is no need for a large amount of nodes.

For instance, I don't have 10 nodes, one for each method of traveling to Zulrah, I have one node, which handles Navigation. Here, the navigation can be set to 10 different choices, each of which have the same underlying implementation.

The validate methods of nodes will called constantly, yes, but typically these computations should be relatively quick and easy, just fetching some boolean values is not too intense.

  • Like 1

Share this post


Link to post
Share on other sites
21 hours ago, Worthy said:

Yes I still use this in my large scripts, such as Zulrah. However, the Zulrah script only has 5 nodes. Everything is encapsulated in an object, and things interact at a higher level, thus there is no need for a large amount of nodes.

For instance, I don't have 10 nodes, one for each method of traveling to Zulrah, I have one node, which handles Navigation. Here, the navigation can be set to 10 different choices, each of which have the same underlying implementation.

The validate methods of nodes will called constantly, yes, but typically these computations should be relatively quick and easy, just fetching some boolean values is not too intense.

Thanks for the answer, very clear!

Share this post


Link to post
Share on other sites
Guest

what if there are 2 tasks that are validated at the same time? where's the priority?

Share this post


Link to post
Share on other sites
On 12/17/2017 at 1:24 PM, rstaiger said:

what if there are 2 tasks that are validated at the same time? where's the priority?

In the framework in the first post, the tasks are looped through serially, each task is validated one by one. It would be undeterministic which task could execute if multiple are valid.

You could design a threaded framework which extends this one (for validating tasks at the same time), including some sort of priority list to see which one should execute.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Similar Content

    • By Worthy
      Welcome to Worthy Scripts
      |w| Zulrah Slayer
      Features
      Automatic Grand Exchange restocking! When out of supplies, the bot can sell loot, ready up, buy more, and continue! Using the resource tracker, the bot automatically calculates how many supplies it needs Essentially with enough GP you can run the bot forever!  Automatic Muling! When the bot has enough wealth, mule over the extra GP and keep it safe! Works with the partner script: |w| Zulrah Muler Here is an example of 2.1B (pure profit) being collected from 33 accounts running for 54 hours:
        Loot tracker. Analyze your drops! This data along with other statistics are saved every run time by the Zulrah Sessions System. Resource tracker. Track every item the bot consumes while playing (and how much it cost!) This data is saved and used to compute exactly how many supplies are needed when doing the automatic Restocking With this tool your pure profit is displayed  Resizeable mode compatible! This is one of the most human-like antibans any botting client can offer. Looking Glass compatible The script now functions smoothly with TRiBot's beta feature Looking Glass Unlimited multi-kill performance The bot will determine if it has enough supplies to start another Zulrah battle after killing the boss the previous time. It can continue doing this until it runs out of food, allowing a single, double, triple, or quad+ kill. Zulrah fight CPU efficient! Ability to run the client minimized.  Dynamically prioritized combat framework Many Travel methods Zul-Andra teleport scrolls Charter Travel Camelot port [via Camelot teleports] Catherby port [via Catherby port lunar teleport] Khazard port [via Khazard port lunar teleport] Fairy Ring Network Fairy ring via Varrock Teleport Fairy ring via Quest Cape Fairy ring via Ardougne Cloak Fairy ring via Salve Graveyard Teleport Fairy ring via slayer ring Fairy ring via House Teleport (mounted) Ornate pool support If so, the script will use castle wars bank instead Jewelry box support If so, the script will use a custom kill / bank loop (with no Ring of Dueling) Or use another player's house! Ability to input a list of names. There is almost every customizeable option for every travel method. Please ask in the discord support server if you have questions  There are also combinations of some of the above travel methods Reorganizes inventory! Drags and drops items like a real player Swaps between gear sets of range and magic Or instead use magic gear only and use a custom positioning algorithm to hide behind pillars Option to skip the blue pattern which deals the most damage   Repairs barrows armor  Supports TRiBot breaking system Hiscores system (below) Tracks GP acquired from Loot, Resources, and computes Profit Tracks rare drops and pets Dynamic signatures (below) Automatic screenshot progress report system every hour
      Detailed session log dump. Keep track of exactly how all your bots do!
      TRiBot Antiban Compliance V2 Level 10/10 The script is also packed with custom statistic-based antipattern I have personally developed. Smart options to determine when to use long range or keep level 1-def Tracks and handles JAD phases flawlessly Deathwalk - SAFE BOSS: never lose your items on death Recharges Trident of the Seas, Trident of the Swamp, Toxic Blowpipe, Serpentine Helm (all forms) Tracks ammunition and recharges special weapons Resizable mode options to optimize gameplay Supports serpentine helmets Supports cooked karambwans Supports special attacks Supports ring of suffering Supports prayer potions / super restores Supports stamina potions Supports summer pies for agility boost Supports imbued heart Supports custom world hopping Supports new rigour and augury prayers Supports vengeance spell with optimal timing Option to use these with rune pouch Supports custom script ending conditions Supports multiple algorithms to fight Zulrah for click-related functions Supports custom f-key bindings Supports in-phase timing: prefer to do actions at the end of phases Picks up and banks the Zulrah pet  
      Official Discord Discussion
      http://discord.gg/yeCVsad
       
      External Documentation Thread
      A lot of the specific information about the features above is on the Documentation thread.
      It can be found by pressing the "READ ME" button on the GUI after the script is purchased.
      It will help you:
      Create an armor preset Decide what gear to wear Set up the GUI to be tailored to your RuneScape character Start the script correctly Other notable information  
      Proggies











      More: http://imgur.com/a/HNaQZ
      Even more: http://imgur.com/a/lsh82

      Requirements
      - 80 to 85+ range/magic (85+ magic necessary as it is the most important stat). If using LG, have at least 85 of both.
      - High defence and hp (>= 70 for barrows), HP recommend at least 75
      - 43+ prayer
      - Regicide, Underground pass, Biohazard, and Plague City required

      Live Hiscores System
      V2 Hiscores (Data wiped and recollected since June 7th, 2019 to track pure profit [loot - resources])
      Dynamic Signatures:
      Automatically load an image of your current stats, which updates as you bot!
      http://www.worthy.rs/tribot-php/ZulrahSlayerV2/sigs/USERNAME_HERE.png Just replace USERNAME_HERE with your TRiBot username (case-sensitive), and copy and paste it the image link itself into your signature here:
       (should be on the bottom right of your signature edit box).
      Does your name have special characters? Simply find the link for your signature in the hiscores link above.


      Pricing
      The Casual Botter
      - 14.99 CREDITS | 1 auth for 2 weeks
      - 24.99 CREDITS | 1 auth for 1 month
      Note you can buy multiple of the above as well

      Gold Farmer's Discount
      - 79.99 CREDITS | 5 auths for 1 month
      - 134.99 CREDITS | 10 auths for 1 month
      - 174.99 CREDITS | 15 auths for 1 month
      - 224.99 CREDITS | 25 auths for 1 month
      - 299.99 CREDITS | 50 auths for 1 month
      Note: the number of auths designates the number of RS accounts you can run on this script at a given time.


      Requirements
      Quests: Plague City, Biohazard, Underground Pass, and Recigide (up to the point where you can access Zulrah)
      Stats: 85+ range, 85+ magic recommended 
       
      Click below to purchase or for FREE TWO HOUR TRIAL:

       
      Troubleshooting Guide:
       
      Happy Botting!
      Worthy 
    • By Gold Pieces
      OSRS scripts often require setting up complex decision trees, in one form or another, in order to achieve the necessary workflow from the bot.
      The OOP solution to this is to create a DecisionTree class and have many DecisionNode classes, each with an ifValid() and an ifNotValid() function.
      However, this results in long convoluted path structures, and can result in an ungodly number of files, if the logic gets complex.
      The FP solution is to create a set of functions that can handle the same logic, using any() and all() methods to mimic nested if statements built with && and || statements.
      This seems a bit more elegant to me, and I have not seen it posted to these forums yet, so I'll leave it here.
      Though the code in this snippet is written in Kotlin, it can be very easily translated to Java to achieve the same effect, though the code will be less concise.
      Conditional (Static Class):
      Example Usage:
      Keep in mind, this is essentially the same as a bunch of nested if statements, though it has the advantage of being more concise and reading a bit clearer, imo.
      I challenge any of you to reproduce the above code using if, else statements and post it below. I promise, it will not be anywhere near as pretty as the code above.
      If someone requests, I will provide the Java equivalent. But let's be honest, Kotlin is the future
    • By Worthy
      Add my discord for communication (worthy#2076)
      Crypto - ETH, BTC, BCH, LTC, USDT, XRP accepted
      Interac E-Transfer is for Canadians only! This method is always accepted
       
      NEW LOW PRICE OF:
      $0.63/M (500m+)
       
       
      PLENTY IN STOCK
       
      Regards,
      Worthy
    • By Worthy
      AutoTalker Infinite
      By Worthy
       


      Features
       
      As many lines as you want to autotalk (will scroll down indefinitely) Custom time interval delay ABCL 10 Auto Accept Trades Alert with a popup window the accepted trade (perfect for leaving the bot running and doing something else, while it talks and accepts trades. It will then alert you a trade has been established, and you can take over).
       
      Steps
      Make sure to select the Trade tab when logged in:

      Click to add:


      Enjoy!

    • By Worthy
      Greetings,
       
      Note that this service is geared towards gold farmers:
      On each authorization, you will be able to run unlimited instances for 6 months on your TRiBot account and only yours.   You will also receive free and quick bug support for the duration of the script instance. This is a premium script designed for a single user, so it will be expensive. If you are looking for a script for your main account or single ironman account, then this service is not for you. You should ideally be an experienced gold farmer if you are using this service.  
      To have a private script created and customized to your needs:
      Add me on Discord (worthy#2076) - always ask for a TRiBot PM to verify. Have a detailed list of steps ready that the bot must do or find a video of these actions being done. Prices, clarifications to detail, timeline (usual turnaround within 1 week), etc. will be discussed on Discord.  
      Private script methods will never be disclosed.
      Pricing will be higher this session due to limited time and request volume. 
       
      Vouches:


      Regards,
      Worthy
    • By Worthy
      AIO Constructor
      By Worthy
       
      Features
      Construct Any Item Including: Planks Bagged plants - FARMING XP! Refills watering cans in house sink Or fetches pre-filled watering cans from the bank Nails Marble Mythical cape
        Multiple Banking Methods Manual banking - Rimmington/Falador, Yanille Ring of Dueling and House Teleports Phials unnoting planks Servant fetch from bank Servant un-note items from inventory
        Synchronized Servant Support Cook Butler Demon Butler
        User Experience This entire script has been rewritten optimized for efficiency and flawlessness  Antiban Compliance (ABC2) Level 10/10 Quick and easy to use GUI setup Script arguments (skip GUI set-up) Slick mousepaint and paint Dynamic signature system (more info below) Hiscores page  
      Set-up
      Start with just a hammer and saw in Inventory. Only if using Servants have coins in Inventory too, or keep them in the servant's money pouch. If using Servants Un-noting have noted planks in Inventory too Only if using Phials Unnoting have noted planks (just the type you are using) in Inventory too. Only if using RoD/Tele Banking have house tabs in Inventory too.  
      Recommended Items to Build
      Levels 1 - 19 → Crude Wooden Chairs (need 138 planks and nails) Levels 19 - 33 → Oak Chairs (need 238 oak planks) Levels 33 - 70  → Oak Larders Levels 70 - 99 → Oak Dungeon Doors 
      OR Levels 52 - 99 → Mahogany Tables (fastest if you have $$)
      OR Levels 47 - 99 → Mythical Capes (requires Dragon Slayer 2 but saves money)
      Creating a preset

      Make sure to create the preset using your mouse only! (no hot-keys).
       
      Notes
      If you find the bot is building and removing items very slowly, you can adjust the ABC2 sleep multiplier.
      This reduces the delays in the script (for Antiban) and is a multiplier on the time which the bot sleeps, ranging from 0.1 - 1.0.
      Say the bot was supposed to sleep for 5 seconds, but with a 0.5x multiplier it now sleeps for only 2.5 seconds.
      A delay of at least 0.5x is recommend.
       
      Script Arguments
       
      Click to buy or try a free 2 hour trial:
       
      4.99 CREDITS for 1 MONTH per Auth
      Or 9.99 CREDITS for 6 MONTHS per Auth
      OR 14.99 CREDITS for 6 MONTHS per 3 Auths
       
      Troubleshooting and Bug Reports

      Check your hiscore ranking here!
      Grab your dynamic signature by going to the follow site:
      http://www.worthy.rs/tribot-php/AIOConstructor/sigs/YOUR_TRIBOT_USERNAME_HERE.png  
      Happy Botting! 
      Worthy
    • By Worthy
      Accessible now through the script's GUI!
      Just click "READ ME!"

      If you are botting on a remote machine and have difficulties browsing the web (and thus the documentation), pressing the "READ ME" button will also print your link and access token in the Client Debug. You may view this link in any web browser for 5 minutes to view the documentation on any computer.
      So, once pressing the "READ ME" button, the following link to view the documentation is generated in the Client Debug: http://worthy.rs/ZulrahSlayer/documentation.php?user=worthy
      (except it will show your TRiBot name).
    • By Worthy
      Welcome to Worthy Scripts
      |w| Zulrah Helper
       
      NOTE: This script does NOT kill Zulrah for you. It guides you through the kill process and tracks information.
      Think of it as a plugin for RuneScape (as the script never directly interacts with the game, but just paints information on the screen).

      Features
      No risk of ban from the script itself (the only other factor could be the Client but @TRiLeZ states it is undetectable) Easy to set-up GUI Hiscores system (below) Automatic screenshot progress report system every hour Supports resizable mode! (side-panels and transparent chat box support). The bot can remind you to Recharge the blowpipe/trident/serpentime helmets Select the best prayers Wear the selected armor Change combat styles Eat food Cure venom Equip rings of recoil Drink prayer/mage/range potions Use special attacks Repair barrows armor Pickups pets The script guides you to kill Zulrah in the most efficient manner, even taking in Melee safe spots into account Now supporting resizable mode! You may even adjust the size of the script while the script is active!
       
      GUI Settings

       
      How it works (note this is a human playing)
       

      How to setup an equipment profile (from my Zulrah Slayer but same concept)
       
      Requirements
      - 80 to 85+ range/hp/def/magic
      - 43+ prayer
      - Regicide, Underground pass, Biohazard, and Plague City required

      Hiscores System
      Link
       
      Proggies

       
      Pricing
      - 9.99 CREDITS | 6 Months | 1 Auth
      Get it here now!

       
      Dynamic Signature

      [center][url=https://tribot.org/forums/topic/53608-/][img=http://www.worthy.rs/tribot-php/ZulrahHelper/sigs/USERNAME_HERE.png][/url][/center]  
      Things to note:
      Green tiles are where you should currently stand Blue tiles are where you should get ready to stand next Red tiles are where Zulrah will spawn Do use karambwans and magic/range potions for faster kills. Do use function keys (esc, f5) so switch tabs quicker. If a karambwan and food is glowing in green, eat the food first and then the karambwan. When battling a certain Zulrah phase, hover over the blue dot on the minimap, and the second Zulrah dives into the ground, click the blue square. Afterwards then wear your new armor, pray the new prayers, eat (if needed), and change combat styles (if needed). Watch this informative video detailing how to deal with the JAD phase  This script is just an overlay, it is not supposed to be meant with LG as it does not interact with the game. TRiLeZ has stated the client is undetectable, and the script does not interact with the game, so there is no chance of a ban, thus LG is not plausible to use. IF using Looking Glass, use 64-bit OSBuddy. Additionally go into File > Settings on the TRiBot client and increase the paint delay to 50+ to reduce lag.  
      With the required stats, you should be able to "legit" Zulrah in a few kills.
      There is also a two hour trial with the script! Don't be alarmed if you don't kill it on the first try though, it could take a few times to get into the rhythm.

      Regards,
      Worthy
    • By Worthy
      Save and Load GUI Settings Tutorial
      by Worthy
       
      In this tutorial
      We will be using java.util Propteries class to save and load settings from your GUI (or anything else that is applicable)

      ________
      Adding the proper variables for preparation.
      In your Main class add the location to save the GUI settings
       
      In your GUI class we must create the Save and Load settings methods
       
      Implementing the methods
      On the "Start" button, we will call saveSettings();
      On the script initiation we will call the loadSettings(); (after the GUI has been loaded)
       
      -->Alternatively you can just create seperate save and load buttons on the GUI.


      Tying everything together:
      The first thing the script will do is declare the File Path, and initiate the Preferences file.
      When the GUI loads, the script will then call loadSettings(), loading the settings (if any).
      If no settings are saved, it well then create a new file in the path.
      Right before the GUI is disposed it will save all the settings the user has applied in TRiBot's storage directory. (You can print out the location if you don't know where that is for your OS).

      _________
      Complete Example script:
      GUISettings.java (Main class)

      GUIExample.java (GUI class)
       
       

      Regards,
      Worthy
       
       
    • Guest
      By Guest
      Looking at the tutorials I didn't notice anyone using a graph-based framework, so I thought that either people hadn't thought of it or at least the newer or less experience programmers weren't aware of using this, so I thought I'd share it. GraphScript is a graph based framework, using a cyclical graph to model the functionality (where each vertex would be the same as a Node or Task from other frameworks) the advantage of this, is that when doing stuff that is rotational such as a skill or simple minigame (I use Wintertodt as an example, something like Hunter would be a fantastic example as well) then it makes sense to use something that more correctly models a human's behavior.
      What do I mean by cyclical? Take a look at this flow chart I made for Wintertodt
       

       
      To breakdown what is happening in the framework, the bottom section is the overlying framework. It decides whether to bank, or go play the minigame. This area also will potentially go into the wait functionality, if the game hasn't started yet but it doesn't need to bank.
       
      The top section is a little more interesting, essentially the arrows are ways to traverse between eachother. So for example burn will never traverse back to fletch, fletch will never traverse back to chop. The advantage of this is that everything is self contained, you don't have to write code worrying about messing up the burn in the fletching class, since that'll be in its own section. For these simple cyclical things it makes everything much more self contained and easy to work with.
       
      The downside is that you have to be more careful in your coding, if it gets stuck in the chopping class for example, while it's below the door outside of the minigame, the entire script is stuck. Typically it's pretty easy to avoid this happening, it just requires a little extra thought.
       
      Here's the source code: https://github.com/Mkerian10/GraphScript
      I re-wrote this on my pc so and I haven't ran through it so if anyone sees any issues lmk. Of course you don't (and probably shouldn't) directly copy this framework, but rather use the ideas to implement your own.
  • Our picks

    • Hello everyone,

      Last week we tried to roll out Auth0 Login, but we lost that battle. Now it's time to win the war!

      Important changes

      When logging into the client, you'll now have to enter your Auth0 account credentials instead of your forums credentials

      Note: 2FA is still handled through your forums account (for the time being)



      Changes for existing users

      You'll have to link your Auth0 account to your forums account here: https://tribot.org/forums/settings/login/?service=11


      Auth0 accounts have been created for most existing users. Please use your forums email address and password to login.



      Important notes

      Make sure to verify your email address upon creating a new Auth0 account


      When we mention your Auth0 account, we mean your account used for auth.tribot.org as displayed below
      • 65 replies
    • To better support the upcoming changes (TRiBot X, new repository), we're switching our login handler to Auth0. Instead of logging in with the standard form, you'll now be required to login through our Auth0 application.

      All existing accounts which have been used within approximately the past year have been imported into Auth0 using the same email and password combination which has been stored on the forums.

      What does this mean for users?

      Your account credentials are now even more securely stored


      You'll be able to login via Facebook, Google, and others in the future


      Is there anything users have to do differently now?

      Existing users: You'll have to login with the standard login, open your Account Settings, then link your Auth0 account


      New users: You'll be redirected to our Auth0 app (auth.tribot.org) where you'll be able to create an account


      Why was this change made?

      The new apps we are creating (such as the new repository) aren't able to use the forums to handle user logins


      To centralize all user accounts in one area


      To ensure that the client login doesn't go down when the forums are having problems


      To speed up our development


      Other considerations

      There's no documentation or official support for using Invision Community combined with Auth0, so there are still a few kinks we're working out


      We're in the works of creating an account management panel specifically for Auth0 accounts (ETA August)


      It's not possible to change email addresses for the time being (this will be resolved this August)


      Changing passwords is a weird process for the time being. To change your password, you'll have to use the "Don't remember your password" tool on the Auth0 login page
        • Like
      • 11 replies
    • Over the past month, we've been working hard on TRiBot's new repository - a much needed update. This change has been deemed necessary for TRiBot X, and will allow us to really speed up development of all aspects of TRiBot.

      Today we are going to share what we've been working on!


      Now you must be wondering what kind of features the new repository will have.... well, you'll have to be patient for a little while longer. We're still figuring out various technical aspects so we can't provide answers to all possible questions. We're also focusing on development rather than writing about it so that everyone can get access to our latest developments at lightning speed. I will however answer a few users' questions.

      We're planning on a release of this early to mid August, giving users some goodies before TRiBot X's release.

      Thank you all for being patient. I hope everyone is excited as much as I am!
        • Like
      • 17 replies
    • Over the past few months, I’ve been working diligently on a new project - TRiBot X. Everything has been written from the ground up, with all of the best practices of software engineering. Every aspect of TRiBot has been re-imagined to support three main goals: flexibility, useability, and reliability.
        • Like
      • 50 replies
    • Come give us feedback on the next version of TRiBot!
        • Thanks
        • Like
      • 86 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...