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 update will:

      Fix GE inventory item positioning bug


      Fix broken object hooks
      • 24 replies
    • This release will:

      Fix some ClosedChannelException bug


      Fix bug in RSObject#getAllTiles


      Add game tab support for "Kourend Favour"
      • 15 replies
    • This release will:

      Fix Settings UI placement bug


      Fix game object location bug


      Fix small layout bug making the client shift up and down


      Fix client crashing bug where loading the client with a small display area will cause the client to crash


      Fix annoying Linux bug relating to painting events and peers


      Fix settings saving bug where settings are saved to disk more often than they should


      Fix RSInterface#isBeingDrawn bug affecting a limited amount of people


      Drop Java 1.7 bytecode version for 1.8


      Important: Since the downloadable RS client uses Java 7, it will no longer be compatible with Looking Glass. To make up for this, we will add support for using other clients such as RuneLite (at a later date).


      This change was necessary to allow us to use Java 8 syntax. It also paves the way for Java 9/10/11 support.
      • 40 replies
    • This update will:

      Fix the RSMenuNode bug which also fixes the bug with bank opening


      Fix the incorrect object positions bug


      Fix and re-enable the LG Objects API Accelerator


      Fix the RSObject#getAllTiles bug
      • 22 replies
    • Try our development release by checking "Development Release" on the TRiBot Loader. Note that these new features are currently in beta.

      This release features:

      Re-sizable mode support for both LG and the regular client


      Slightly improved login bot


      Removed final access modifiers from API classes


      Added RSServer hook wrapper to get the client's cached list of server/world info


      [NEW] Bug fix for intelligent banking


      [NEW] Improvement to the stability of LG over time


      [NEW] Vastly improved the reliability and speed of Screen#getColorAt on both LG and the regular client


      [NEW] Fix LG login problems


      [NEW] Fixed re-sizable mode container bug


      [NEW] Fixed re-sizable mode mouse bug


      [NEW] Use of public constants in the Banking API


      [NEW] Use of other various constants such as Projection#NULL_PT and Screen#EMPTY_COLOR



      More features to come very soon!

      Please test it and let us know here if there are any new bugs introduced in this release.
      • 12 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×