A quick guide on interfaces

I just had to interact with RS interfaces for a script I’m writing and found there to be little to no documentation on RS interfaces so heres a short and simple guide to them.

Interfaces are windows in RS. It appears than the game window is made up of interfaces. It could be the chat box, inventory…etc. RSPeer has API functions to interact with the common interfaces which you may have used before.

Examples

Bank.close()
Production.isOpen / Production.initiate(productionIndex)

If you encounter an interface which the RSPeer API hasn’t got convienent methods for, you have to write the interactions yourself.

The game is made up of InterfaceComponent’s. You can grab one of those interface components using the Interfaces class.

Example:

InterfaceComponent ic = Interfaces.get(componentGroup, componentIndex);

The variables componentGroup and componentIndex are both type int.

You can find those variables by using the RSPeer client, enabling MenuActionDebug in the Settings -> Debug menu of the client and then interacting with the interface component.

You’ll receive some output like this:

[INFO] Sun Jun 21 04:46:24 AFT 2020: Info: ComponentAction<INTERFACE_ACTION>[actionIndex=1|componentUid=29229090|componentGroup=446|componentIndex=34]

You can easily plug those variables into the Interfaces.get method.

Some things to consider, Interfaces.get() can return NULL if it doesn’t find an interface. It can also return an interface component that you can’t nessecarily see or interact with. Checking whether an interface is open then should use two checks

interfaceComponent != null && interfaceComponent.isVisible();

You can use the .interact() method of InterfaceComponent to interact (duh!)

interfaceComponent.interact(“Make”);

This also accept ActionOpcodes (i.e ActionOpcode.USE_ITEM) or similar.

There’s a short, simple tutorial for those who’ve never worked with interfaces before. It’s not the best tutorial in the world and I wrote it super quick. I only learned this information myself about 30 minutes ago and figured I’d write something real quick as I struggled to find any reasonable documenation on interfaces.

Thanks for reading!

Great quick guide, however, it’s recommended to avoid as many static interface IDs where possible due to the fact they can change. I believe the API already provides you with interface addresses which are essentially the parent interface (I think, it’s been a while). Use those in combination with rspeer’s query methods to properly find interfaces. This is done by using Interfaces.newQuery(). You’re then able to use the information provided in the Interface finder to filter out what you need and don’t need, eg. Visibility, actions, text and a much more. That way, if Jagex were to ever change the interface ids, which they do occasionally, your script has a higher chance of maintaining functionality.

Thank you for the comments. I’ll look into it today and possibly update the thread to reflect my findings.