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

    • Please welcome our new developers, @JoeDezzy1, @erickho123, @Encoded, and @wastedbro.

      These members will be responsible for working on, maintaining, and improving TRiBot.

      This means that bug fixes and improvements will now come at a much faster pace! We're committed to providing users with the best botting experience possible!
        • Thanks
        • Like
      • 30 replies
    • This release includes:

      More 3rd party libraries for script writers to use


      Apache Commons Codec


      Apache Commons Collections


      Apache Commons Configuration


      Apache Commons IO


      Apache Commons Lang


      Apache Commons Math


      GSON


      Guava


      JFoenix




      Hint arrow API


      Game#getHintArrowX


      Game#getHintArrowY




      Fix player hooks including Player#getSkullIcon and Prayer#getPrayerIcon
        • Thanks
        • Like
      • 39 replies
    • This update includes:

      Fix broken hooks


      Fix login bot for the message "No reply from login server. Please wait 1 minute and try again."


      Fix bug relating to which bot tab is sent human input


      General#randomLong bug fix involving negative numbers


      Fix GE API



      Please note: There are still some issues with the login bot due to a change in the game mechanisms handling the login screen. We're working on a fix and will upload it when ready.
        • Thanks
        • Like
      • 37 replies
    • This release will:

      Fix key event handling issue


      Fix other event handling issue


      Fix RSServer hook


      Update world hopper to have it use OCR, thanks to Todd


      Use proper disposal of old Graphics objects


      Reformat code


      Rearrange code


      Organize code imports


      Apply around 8000 automated code refactorings


      Make preparations for Java 9


      Fix 11 various bugs


      Add more reliable debugging support


      Fix mouseEntered/Exited event dispatching bug


      Fix minimap walking bug where it opens the map


      Fix broken hooks for today's game update
        • Thanks
        • Like
      • 100 replies
    • This update will:

      Fix GE inventory item positioning bug


      Fix broken object hooks
        • Like
      • 27 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×