Jump to content
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 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
      • 30 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
    • This release will:

      Add LG support for Runelite


      Fix NPCChat issues


      Fix a bug where the camera angle setter would just hold down a key for 5 seconds (the timeout)


      Slightly adjust the rotation via keys to be more accurate


      Add the ability for asynchronous camera movement via keys


      Make Camera rotation via mouse more fluid, with more antiban, and work much better in resizable mode


      Add a "Camera#setCamera" method, allowing the rotation and angle to be set in parallel


      Increase the likelihood of using the mouse for camera movements


      Add support for adjusting the camera to positionable entities (Positionable#adjustCameraTo)



      Upcoming updates:

      Improved CLI support


      Much more



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

      Allow for clicking through the chat box when possible (Thanks @Todd)


      Fix Combat#selectIndex (Thanks @Encoded)


      Ensure worlds stay sorted and added a check to avoid misclicks in the in-game world hopper (Thanks @erickho123)


      Fix out-dated Options API interface indices (Thanks @Todd)



      Upcoming updates:

      Break handler bug fix


      Improved CLI support


      Much more



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

      Fix login bot after today's game update (Thanks @JoeDezzy1)


      Fix latest in-game world hopping issues (Thanks @erickho123)


      Compact Settings UI and set location relative to TRiBot (Thanks @JoeDezzy1)


      Fix an older implementation of GrandExchange#getWindowState (Thanks @JoeDezzy1)


      Improve the preformance of NPCChat by only searching in certain interface parents (Thanks @JoeDezzy1)



      Upcoming updates:

      Break handler bug fix


      Improved CLI support


      LG support for RuneLite


      Much more



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

    No registered users viewing this page.

×