Jump to content

Nightmare Zone


Recommended Posts

Posted

how does this work? how can i get some number out of this: yes am a noobie, thanks!

public int getCurrentDrinkLevel() {
        RS2Widget widget = getWidgets().get(202, 1, 9);
        if (widget != null && widget.isVisible() && widget.getMessage() != null)
            return Integer.parseInt(widget.getMessage().replace(",", ""));
        return 0;
    }

 

Posted (edited)

This method reads a RS2Widget for a message, a widget is a UI component in runescape, in this case the widget to be read is the absorption widget in NMZ. 

To read a widget you must first get an instance of it. The line RS2Widget widget = getWidgets().get(202, 1, 9) does that. The parameters in the get method are .get(rootID, child+ ID, child++ ID). Every widget can be identified by these 3 parameters, in some cases it can be identified by 2. 

It is better to obtain widgets through only the rootID through an API method that can identify widgets via a unique sprite, text, options, ect because child IDs may change over game updates. However I have use the above snippet in my own code for several months and have not seen IDs change yet. If you are just learning widgets don't bother with the better practice and just get it working first. 

This image shows an example of the absorption widget's ids and the widget itself's instance variables. The message instance variable contains the player's absorption level. 

https://imgur.com/8U5TKE6

 

Edited by PayPalMeRSGP
Posted (edited)
4 hours ago, PayPalMeRSGP said:

This method reads a RS2Widget for a message, a widget is a UI component in runescape, in this case the widget to be read is the absorption widget in NMZ. 

To read a widget you must first get an instance of it. The line RS2Widget widget = getWidgets().get(202, 1, 9) does that. The parameters in the get method are .get(rootID, child+ ID, child++ ID). Every widget can be identified by these 3 parameters, in some cases it can be identified by 2. 

It is better to obtain widgets through only the rootID through an API method that can identify widgets via a unique sprite, text, options, ect because child IDs may change over game updates. However I have use the above snippet in my own code for several months and have not seen IDs change yet. If you are just learning widgets don't bother with the better practice and just get it working first. 

This image shows an example of the absorption widget's ids and the widget itself's instance variables. The message instance variable contains the player's absorption level. 

https://imgur.com/8U5TKE6

 

thanks. i already knew this, i know the basics and i know how to use widgets (for example interacting with them etc etc.), BUT how can i use this snippet what i posted in my code? where do i put it? do i need to do something like if (getCurrentDrinkLevel > 100) ??? thats what i ment... or do i need to put my absorption level number between these " "'s in the snippet? *i tried something stupid like this: 

if (widget.getMessage().contains("970")) {
                    inventory.interact("Drink", "Absorption potion(4)", "Absorption potion(3)", "Absorption potion(2)", "Absorption potion(1)");
                }

 

Edited by alkku15
Posted
14 hours ago, alkku15 said:

thanks. i already knew this, i know the basics and i know how to use widgets (for example interacting with them etc etc.), BUT how can i use this snippet what i posted in my code? where do i put it? do i need to do something like if (getCurrentDrinkLevel > 100) ??? thats what i ment... or do i need to put my absorption level number between these " "'s in the snippet? *i tried something stupid like this: 

if (widget.getMessage().contains("970")) {
                    inventory.interact("Drink", "Absorption potion(4)", "Absorption potion(3)", "Absorption potion(2)", "Absorption potion(1)");
                }

 

It's clear that the method you've posted returns an Integer, so you'd check getCurrentDrinkLevel() > 100. The fact you can't figure that out though suggests to me you need to go and read up a little bit more on basic variables / methods. 

Posted
On 5/19/2018 at 10:03 PM, HeyImJamie said:

It's clear that the method you've posted returns an Integer, so you'd check getCurrentDrinkLevel() > 100. The fact you can't figure that out though suggests to me you need to go and read up a little bit more on basic variables / methods. 

ye ikr im a noob at coding but why doesn't this work? i drank abs all the way to 450, then ran the script for 1min didnt do anything

if (getCurrentDrinkLevel() < 500) {
                inventory.interact("Drink", "Absorption potion(4)", "Absorption potion(3)", "Absorption potion(2)", "Absorption potion(1)");
            }

 

Posted
45 minutes ago, alkku15 said:

ye ikr im a noob at coding but why doesn't this work? i drank abs all the way to 450, then ran the script for 1min didnt do anything

if (getCurrentDrinkLevel() < 500) {
                inventory.interact("Drink", "Absorption potion(4)", "Absorption potion(3)", "Absorption potion(2)", "Absorption potion(1)");
            }

 

The potions are called Absorption(4). not Absorption potion(4). You have ur strings wrong. 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...