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  
swagg

Grabbing RSInterfaceComponent?

Recommended Posts

Sorry, it's .getChild() not .get()

 

Don't forget to null check!

Weirdly enough I can't get the text from the RSInterfaceComponent, however I can with a child? :o

	public void toggleRoof() {		RSInterface roofText = Interfaces.get(ROOF_MASTER, ROOF_TEXT_CHILD).getChild(ROOF_TEXT_COMPONENT);		RSInterface roofToggle = Interfaces.get(ROOF_MASTER, ROOF_TOGGLE_CHILD);		RSInterface textTest = Interfaces.get(261, 57); // just for testing purposes		if (GameTab.open(GameTab.TABS.OPTIONS)) { // opens option tab			randomSleep();			if (roofToggle.hover()) { // hover over toggle button				General.sleep(2000, 4000); // takes some time for runescape text to come up on screen				println(textTest.getText()); // just for testing purposes (works)				println(roofText.getText()); // doesn't work?				if (roofText.getText() != null) { // null check					if (roofText.getText().equalsIgnoreCase("Always hide roofs (currently off)")) { // should click						roofToggle.click();					}					if (roofText.getText().equalsIgnoreCase("Always hide roofs (currently on)")) { // shouldn't click					toggledRoof = true;					}				}			}		}		else			toggledRoof = false;	}

Full code: (run anywhere)

package scripts;import org.tribot.api.DynamicClicking;import org.tribot.api.General;import org.tribot.api.input.Mouse;import org.tribot.api2007.Camera;import org.tribot.api2007.GameTab;import org.tribot.api2007.Interfaces;import org.tribot.api2007.Login;import org.tribot.api2007.NPCChat;import org.tribot.api2007.NPCs;import org.tribot.api2007.Objects;import org.tribot.api2007.Player;import org.tribot.api2007.types.RSInterface;import org.tribot.api2007.types.RSNPC;import org.tribot.api2007.types.RSObject;import org.tribot.script.Script;import org.tribot.script.ScriptManifest;@ScriptManifest(authors = { "Swagg" }, category = "Tools", name = "SwagTutorial", description = "Swagg's tutorial", version = 1.00)public class SwagTutorial extends Script {		boolean stopScript = false; // stops script (jumps out of main loop) when  true	boolean toggledRoof = false; // failsafe to not repeat toggling roff off it if already has		int mouseSpeed = randomizeNumber(30, 80);	int minMouseSpeedDifference = -mouseSpeed/7; // ~ -14%	int maxMouseSpeedDifference = mouseSpeed/7; // ~ +14%		// INTERFACES	int ROOF_MASTER = 261;	int ROOF_TOGGLE_CHILD = 11;	int ROOF_TEXT_CHILD = 60;	int ROOF_TEXT_COMPONENT = 2;	int PRIVATE_STATUS_MASTER = 548;	int PRIVATE_STATUS_CHILD = 14;	int CHAR_CREATION_MASTER = 269;	int CREATION_ACCEPT_BUTTON = 99;	int CHAR_CREATION_MALE = 138; // never used (since male is default)	int CHAR_CREATION_FEMALE = 139;	int GETTING_STARTED_MASTER = 372;			// Rotate (outfit part) left/right button interfaces	// In arrays: 0 = Rotate left, 1 = Rotate right	int[] CREATION_CHILD_HEAD = { 106, 113 };	int[] CREATION_CHILD_JAW = { 107, 114 };	int[] CREATION_CHILD_TORSO = { 108, 115 };	int[] CREATION_CHILD_ARMS = { 109, 116 };	int[] CREATION_CHILD_HANDS = { 110, 117 };	int[] CREATION_CHILD_LEGS = { 111, 118 };	int[] CREATION_CHILD_FEET = { 112, 119 };	int[] CREATION_CHILD_HAIR_COLOR = { 105, 121 };	int[] CREATION_CHILD_TORSO_COLOR = { 123, 127 };	int[] CREATION_CHILD_LEGS_COLOR = { 122, 129 };	int[] CREATION_CHILD_FEET_COLOR = { 124, 130 };	int[] CREATION_CHILD_SKIN_COLOR = { 125, 131 };			public boolean onStart() {		while (Login.getLoginState() != Login.STATE.INGAME) {			// waiting to be logged in			sleep(300);		}		Mouse.setSpeed(mouseSpeed);		General.sleep(1000, 4000);		return true;	}	@Override	public void run() {		if (onStart()) {			while (!stopScript) {				loop(); // main loop			}		}	}		public void loop() {		randomizeMouseSpeed(); // randomizes mouse speed from ~ +14% to ~ -14% of first generated mouse speed 				if (NPCChat.getClickContinueInterface() != null) {			randomSleep();			NPCChat.clickContinue(true);		}		if (findNPC("Skippy") == false && noChatConversation()) { // if can't find Skippy and there's no NPC conversation			randomSleep();			privateOff(); // set friends status to private			if (!toggledRoof) { // if script didn't already toggle to hide roof (failsafe)				randomSleep();				toggleRoof(); // hide roof			}			if (noChatConversation()) { // if no conversation is open (failsafe)				println("Couldn't find Skippy. Assuming tutorial is finished.");				stopScript = true; // stops script by breaking the main loop			}		}		if (NPCChat.getSelectOptionInterface() != null) {			randomSleep();			NPCChat.selectOption("Send me to Lumbridge now.", true);			NPCChat.selectOption("No, I don't want that. Send me to Lumbridge now.", true);		}		if (isCharCreationUp())	{ // if the first tutorial character outfit window is up			randomSleep();			randomizeOutfit(); // randomizes gender, clothes, skin color etc		}		if (isGettingStartedUp()) { // if in first tutorial house			randomSleep();			if (noChatConversation()) // if there's no NPC conversation			talkToNPC("Skippy");		}		sleep(100);	}			// METHODS (rest of the script)		public int randomizeNumber(int a, int  {		int number = General.random(a, ;		return number;	}		public void randomizeMouseSpeed() {		Mouse.setSpeed(mouseSpeed + (randomizeNumber(minMouseSpeedDifference, maxMouseSpeedDifference)));	}	    public boolean findNPC(String str) {        return getNPC(str) != null;    }        // RSObject not used, keeping for future updates/projects    public boolean findObject(String str) {        return getObject(str) != null;    }        public RSNPC getNPC(String str) {        RSNPC[] npc = NPCs.find(str);        if(npc.length > 0) {        	int i = randomizeNumber(0, npc.length-1);            return npc[i];        }else{            return null;        }    }    // RSObject not used, keeping for future updates/projects    public RSObject getObject(String str) {        RSObject[] object = Objects.find(30, str);        if(object.length > 0) {        	int i = randomizeNumber(0, object.length-1);            return object[i];        }else{            return null;        }    }    	public boolean noChatConversation() {		if (NPCChat.getClickContinueInterface() == null && NPCChat.getSelectOptionInterface() == null) {			return true;		}		else			return false;	}    	public void randomSleep() {		General.sleep(200, 1000);	}    	public void privateOff() {		// set private off	}		public void toggleRoof() {		RSInterface roofText = Interfaces.get(ROOF_MASTER, ROOF_TEXT_CHILD).getChild(ROOF_TEXT_COMPONENT);		RSInterface roofToggle = Interfaces.get(ROOF_MASTER, ROOF_TOGGLE_CHILD);		RSInterface textTest = Interfaces.get(261, 57); // just for testing purposes		if (GameTab.open(GameTab.TABS.OPTIONS)) { // opens option tab			randomSleep();			if (roofToggle.hover()) { // hover over toggle button				General.sleep(2000, 4000); // takes some time for runescape text to come up on screen				println(textTest.getText()); // just for testing purposes (works)				println(roofText.getText()); // doesn't work?				if (roofText.getText() != null) { // null check					if (roofText.getText().equalsIgnoreCase("Always hide roofs (currently off)")) { // should click						roofToggle.click();					}					if (roofText.getText().equalsIgnoreCase("Always hide roofs (currently on)")) { // shouldn't click					toggledRoof = true;					}				}			}		}		else			toggledRoof = false;	}		public boolean isCharCreationUp() {		return (Interfaces.get(CHAR_CREATION_MASTER) != null);	}		public boolean isGettingStartedUp() {		return (Interfaces.get(GETTING_STARTED_MASTER) != null);	}		public void randomizeOutfit() {		if (randomizeNumber(0, 4) == 0) {		RSInterface female = Interfaces.get(CHAR_CREATION_MASTER, CHAR_CREATION_FEMALE);		female.click();		}		randomSleep();		randomizePart(CREATION_CHILD_HEAD);		randomizePart(CREATION_CHILD_JAW);		randomizePart(CREATION_CHILD_TORSO);		randomizePart(CREATION_CHILD_ARMS);		randomizePart(CREATION_CHILD_HANDS);		randomizePart(CREATION_CHILD_LEGS);		randomizePart(CREATION_CHILD_FEET);		randomizePart(CREATION_CHILD_HAIR_COLOR);		randomizePart(CREATION_CHILD_TORSO_COLOR);		randomizePart(CREATION_CHILD_LEGS_COLOR);		randomizePart(CREATION_CHILD_FEET_COLOR);		randomizePart(CREATION_CHILD_SKIN_COLOR);		RSInterface accept = Interfaces.get(CHAR_CREATION_MASTER, CREATION_ACCEPT_BUTTON);		accept.click();		}				public void randomizePart(int[] outfitPart) {			if (randomizeNumber(0, 1) == 0) {				RSInterface left = Interfaces.get(CHAR_CREATION_MASTER,	outfitPart[0]);				int timesToClick = randomizeNumber(0, 5);				for (int j = 0; j < timesToClick; j++) {					randomSleep();					left.click();				}			} else {				RSInterface right = Interfaces.get(CHAR_CREATION_MASTER, outfitPart[1]);				int timesToClick = randomizeNumber(0, 5);				for (int j = 0; j < timesToClick; j++) {					randomSleep();					right.click();				}			}			randomSleep();		}			public boolean talkToNPC(String str) {		RSNPC npc = getNPC(str);		if (npc != null && !Player.isMoving()) {			randomSleep();			if (npc.isOnScreen()) {				DynamicClicking.clickRSNPC(npc, "Talk-to");			} else {				Camera.turnToTile(npc);			}		}		return false;	}}
Edited by swagg

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
      • 24 replies
    • Come give us feedback on the next version of TRiBot!
        • Thanks
        • Like
      • 70 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...