Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
thedark115

Attempting to work with an Interface

Recommended Posts

Hi, so to begin with I am still new to scripting but I do have a bit of knowledge in Java. Right now i'm currently stuck on a small part where I am trying to identify an item within an interface, The interface ID is 300,2. The item i'm trying to interact with inside of this interface is labelled as 300,2,8 and the Item id  is 970.

This is within a shop, and I am trying to right click, buy 10 but I can't seem to make it work. I don't know what to do beyond this point, and i've spent hours watching tutorials but none cover the interaction with interface i'm trying to do. Also I have tried reading through source files of scripts interacting with shops, but cannot seem to grasp how an array is created and how to navigate through the array and interact within the set bounds of the array created.

My current lack of knowledge: Create an array inside of an interface, interact with an item inside the bounds I set inside of the array created. 

I don't know if TriBot handles interfaces like these in a simpler manner in the API, but I have definitely sought out other ways for this and have always come up empty handed.

 

I understand that at this point most people pay money for private teaching, but i've currently spent all of my money on my car to be fixed so I am going to you guys. Anyone willing to lend a hand? A clean explanation of how this works is all I ask, I'm not looking for anyone to do my code for me. If you can explain how the array is set up and works, and how to create bounds inside of the array that would be great. I can currently see the bounds of the item in the shop myself when I select the item in an interface explorer, but have no clue how to manually create the bounds within the script. Also should I change the shop to a banking interface in case the item runs out of stock? 

 

Current state of code after dumping and restarting from nothing:

	private boolean buyPapyrus() {
		RSInterfaceChild papyrus = Interfaces.get(300,2);
		if(papyrus != null && !papyrus.isHidden() && !Inventory.isFull() && hasPapyrus()){
			
		}
		return false;
	}
	
	private boolean hasPapyrus() {
		RSItem[] items = Interfaces.get(300, 2).getItems();
		for (int i = 0; i < items.length; i++)
			if (items[i].getID() == 970) {
				return true;
			}
		return false;
	}

I will implement a loop for buying the items that will be non-repetetive and include ABCL2. This script is in development and is planned to be released publicly.

Share this post


Link to post
Share on other sites
On 7/10/2016 at 6:38 PM, FALSkills said:

Shop items are stored as RSInterfaceComponent objects. You should call .getChildren() on the interface (300,2) to get the components of the shop as an array, and each component stores information such as item ID, name, stack, etc.

You're awesome, thank you!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Our picks

    • This release will:

      Add new internal framework for capturing exceptions


      Fix issue with not selecting the last column in world hopper (Thanks @Todd)


      Add a message about pin usage in Banking#openBank (Thanks @Todd)


      Disable the firewall by default (Thanks @Todd)


      Fix handling of the welcome screen after login (Thanks @Encoded)


      Fix wrong amount bank withdrawal (Thanks @Encoded)


      Fix Screen#isInViewport


      Fix Game#isInViewport (Thanks @Encoded)


      Call onBreakEnd for ListenerManager Breaking Listeners (Thanks @Encoded)


      Fix Prayer#getPrayerPoints NumberFormatException (Thanks @JoeDezzy1)



      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Thanks
        • Like
      • 19 replies
    • This release will:

      Fix LG for both OSBuddy and RuneLite


      Fix issue where the resizable client isn't able to be made smaller (Thanks @JoeDezzy1)


      Fix detection of the logout game tab when resizable mode and side panels are enabled (Thanks @JoeDezzy1)


      Add initial support for Sentry to allow us to identify and easily debug exceptions happening with all TRiBot users


      Add methods to determine if the bank is actually loaded, and not just the overarching interface (Thanks @wastedbro)



      Upcoming updates:

      Improved CLI support


      Full Sentry support


      Much more
        • Like
      • 64 replies
    • This release will:

      Fix NPE in Camera API (Thanks @wastedbro)


      Update deposit box interface ids (Thanks @Encoded)


      Add various bank methods (Thanks @wastedbro)


      Banking#getWithdrawXQuantity


      Banking#getDefaultWithdrawQuantity


      Banking#arePlaceholdersOn




      Fix resizeable minimap bug (Thanks @wastedbro)


      Remove Java 8 requirement


      Please note: TRiBot is not yet fully compatible with Java 10+




      Fix the break handler issues by ensuring the break handler thread never gets paused


      Fix broken settings hooks



      Upcoming updates:

      Improved CLI support


      Much more



      Note: If you are using LG, please restart both the RS client and TRiBot
        • Like
      • 68 replies
    • This release will:

      Add support for using custom F key bindings to switch between game tabs (Thanks @erickho123)


      Fix tab opening for "Skills" and "Kourend Tasks" (Thanks @erickho123)



      Note: If you are using LG, please restart both the RS client and TRiBot
        • Like
      • 34 replies
    • This release will:

      Fix an issue where breaks would stop firing


      Fix Combat#getWildernessLevel, use dynamic search for text and cache ID for later calls


      Fix an NPE in the Combat API


      Fix Mouse#leaveGame bug where the mouse wouldn't actually leave the game screen
        • Like
      • 21 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×