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.
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.
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!)
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!