Jump to content

Nightmare Zone


alkku15

Recommended Posts

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;
    }

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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)");
            }

 

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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