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

Sell OSRS Gold
Sign in to follow this  
ScriptsForMains

Setting "Fixed Window Mode" and "Hide Roofs"

Recommended Posts

It breaks daxWalker to have them open... Tribot's built in versions weren't working I searched forums and couldn't find this premade...  Here you go.

 

package scripts;

import org.tribot.api.General;
import org.tribot.api.Timing;
import org.tribot.api2007.GameTab;
import org.tribot.api2007.Interfaces;
import org.tribot.api2007.Objects;
import org.tribot.api2007.Options;
import org.tribot.api2007.types.RSInterface;
import org.tribot.api2007.types.RSInterfaceMaster;
import org.tribot.api2007.types.RSObject;
import org.tribot.script.Script;
import org.tribot.script.ScriptManifest;

import java.util.function.BooleanSupplier;

import static org.tribot.api2007.Interfaces.get;

public class SetSettings{
    private static RSInterfaceMaster optionTab = Interfaces.get(261);
    private static int optionsSet;
    public boolean setRoofAndFixedDisplay() {
        for (int i = 0; i < 3; i++) { //Attempts to set settings 3 times in case of lag
            optionsSet = 0;
            General.println("Attempting to open \"Options\" tab");
            if (GameTab.open(GameTab.TABS.OPTIONS)) {
                General.println("Options tab opened, attempting to set Fixed Window Size and Hide Roofs");
                optionTab = Interfaces.get(261);
                Timing.waitCondition(() -> {
                    return optionTab != null;
                }, 10000);
                if (optionTab != null) {
                    if (optionTab.getChild(1) != null) {
                        optionTab.getChild(1).getChild(0).click();
                        Timing.waitCondition(() -> {
                            return optionTab.getChild(1).getChild(0).getTextureID() == 762;
                        }, 10000);
                        General.sleep(250,1000);
                        if (optionTab.getChild(1).getChild(0).getTextureID() == 762)
                            if (optionTab.getChild(33).getChild(0).getTextureID() == 1141) {
                                optionTab.getChild(33).click();
                                Timing.waitCondition(() -> {
                                    return optionTab.getChild(33).getChild(0).getTextureID() == 1150;
                                }, 10000);
                            }
                        if (optionTab.getChild(33).getChild(0).getTextureID() == 1150) {
                            optionsSet++;
                            General.println("Fixed display set");
                        }
                        General.sleep(5000);
                        optionTab.getChild(35).click();
                        Timing.waitCondition(() -> {
                            return Interfaces.get(60) != null;
                        }, 5000);
                        if (Interfaces.get(60) != null) {
                            if (Interfaces.get(60).getChild(14) != null) {
                                if (Interfaces.get(60).getChild(14).getTextureID() == 761) {
                                    Interfaces.get(60).getChild(14).click();
                                    Timing.waitCondition(() -> {
                                        return Interfaces.get(60).getChild(14).getTextureID() == 762;
                                    }, 10000);
                                }
                                if (Interfaces.get(60).getChild(14).getTextureID() == 762) {
                                    General.println("Roof hiding set");
                                    optionsSet++;
                                }
                            }
                            Interfaces.get(60).getChild(2).getChild(11).click();
                        }
                    }
                }
            }
            General.println("Options correctly set: "+optionsSet+"/2");
            if (optionsSet == 2) {
                General.println("Successfully set settings.");
                return true;
            }
        }
        General.println("Failed to set settings.");
        return false;
    }
}

Share this post


Link to post
Share on other sites

Here's a few tips:

You have to null check most things from the API. Check the docs to see if a specific method can potentially return null. 

To build off what netami said, check out laniax's entity selector to dynamically select interfaces so you don't need to hard code any child/component ids (these change often in updates). It's generally okay to hard code master ids though because they don't usually change. https://github.com/Laniax/Entity-Selector

Try to avoid magic numbers; create a constant variable to hold data (static final)

  • Like 1

Share this post


Link to post
Share on other sites

This is why I chose the Tribot community...  I love the activeness of the forums and the fact that you guys are willing to help me out like this.  
 

6 hours ago, FALSkills said:

DaxWalker works perfectly fine with resizable enabled. I also have roofs enabled on one of my servers due to a weird jagex cache issue and my bots are working, but it definitely can cause problems.

Specifically, problems at Wizard Tower.  I made an imp catcher bot and if the door was closed and the camera positioned a certain way, it would break.  Instead of rotating the camera on every script that uses DaxWalker, I decided to hide roofs.  I always see people's scripts saying "Use fixed mode and have hide roofs enabled"...  I thought resizable broke it too somehow.  
 

1 hour ago, Netami said:

In addition to what Fals noted, there's a decent chance your code for the interfaces will break with every game update since you're using static IDs to locate the buttons. 

 

1 hour ago, Naton said:

Here's a few tips:

You have to null check most things from the API. Check the docs to see if a specific method can potentially return null. 

To build off what netami said, check out laniax's entity selector to dynamically select interfaces so you don't need to hard code any child/component ids (these change often in updates). It's generally okay to hard code master ids though because they don't usually change. https://github.com/Laniax/Entity-Selector

Try to avoid magic numbers; create a constant variable to hold data (static final)

Thank you for this!  I wasn't sure how to do it... I thought about using Dynamic Clicking and moving the mouse to the different Interface boxes, then checking click options.  It seemed like a lot of work so I used IDs and was just gonna update with game updates.  This is incredibly helpful.  

Is this what you mean when you mention I'm not null checking?

if (optionTab.getChild(1) != null) {
                        optionTab.getChild(1).getChild(0).click();

I only didn't null check here because if optionTab.getChild(1) isn't null, it means you can see the box that has the "Display", "Audio", "Chat", and "Controls" tabs and so presumably, you can see the Components. Should I be null checking every single interface child before clicking to be safe?  

Share this post


Link to post
Share on other sites
2 hours ago, ScriptsForMains said:

Is this what you mean when you mention I'm not null checking?

if (optionTab.getChild(1) != null) {
                        optionTab.getChild(1).getChild(0).click();

Values returned by methods may not be consistent.

Even if the first line passes the null check, subsequent calls to the same method could very well return null, and attempting to access fields or methods from this value will throw a NPE.

 

The correct way of null checking is to cache the returned value into a variable. Null check the variable, then if it turns out to be non-null, proceed to use it as a reference to a valid object.

Example (using the 2 lines above):

RSInterface i = optionTab.getChild(1);
if (i != null) {
    RSInterface ii = i.getChild(0);
  	if (ii != null) {
           ii.click();
    }
}

 

I do not recommend using this in your code, as we have better alternatives.

This example is to demonstrate the correct way of null checking. All methods that can return null should be handled as such. It might require writing more lines of code, but this is the correct way of using the API.

 

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.

Sign in to follow this  

  • Our picks

    • 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
      • 31 replies
    • Come give us feedback on the next version of TRiBot!
        • Thanks
        • Like
      • 74 replies
    • TRiBot is looking to improve a lot of its customer relationship management, customer on boarding process, customer experience, design elements, community engagement and pretty much everything else you can imagine when it comes to marketing.

      Our goal: To ensure that the marketing done TRULY reflects the experience and does not shine an inaccurate light on what TRiBot is lacking in.

      So I ask, what do you love about TRiBot and what do you hate about TRiBot? What does O S Bot, Rune M8, PowR Bot and Dre amBot do better? (yes I purposely didn't spell it right 😂).

      Love, 

      RileyZ
        • Like
      • 23 replies
    • Over the last three weeks, I've been working on upgrading our server infrastructure. It's finally ready and is now live!

      Why?

      Increased reliability - less server errors


      Increased availability - less downtime


      Increased security - keeping us and you secure


      Increased capacity - ability to serve you better


      Increased speed - less waiting for things to load


      Faster development - server and service updates will come faster


      What are the changes?

      Move from a single AWS EC2 instance to AWS ECS (Elastic Container Service)


      Distributed computing


      Load balancing


      Git management of server files and filesystem


      Redis caching


      How?

      AWS ECS (with 10 EC2 instances)


      AWS ElastiCache (Redis)


      AWS Load Balancing


      AWS EFS (Elastic file system)


      Please bare with us as I continue to tune the server for maximum performance. Slow loading speeds may occur temporarily. I thank everyone for their patience.

      Please post on this thread if you experience any issues other than slow loading times.
        • Like
      • 51 replies
    • This release will:

      Fix prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)


      Improve banking API (Thanks @Encoded)


      Adds methods for returning and using Java Lists, rather than arrays


      Slightly randomizes some hardcoded behaviour


      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable


      Other back-end improvements





      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Sad
        • Haha
        • Thanks
        • Like
      • 90 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...