Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Turning string values of a Widget into an integer


    Recommended Posts

    Hey all!

    I am wondering how to access the string values of a widget as an integer. Suppose I have the following code:

    String upper = getWidgets().getWidgetChild(383,3,11).getText();
                String lower = getWidgets().getWidgetChild(383,3,5).getText();
                String upperv = upper.replace("coins", "");
                String lowerv = lower.replace("coins", "");
                int uppervalue = Integer.parseInt(upperv);
                int lowervalue = Integer.parseInt(lowerv);
                int margin = uppervalue - lowervalue;
                WidgetChild lowest = getWidgets().getWidget(383).getChild(3).getChild(5);            
                if (lowest != null && margin > 2) {
                    sleep(Calculations.random(3000, 4000));
                    WidgetChild limit = getWidgets().getWidget(465).getChild(24).getChild(49); 
                    if (limit != null) {
                        sleep(Calculations.random(1000, 1500));

    Here I try to calculate the margin of an item by taking the widget values of the upper and lower limit. I try to convert the strings into an integer and then substract them to have the margin. I then use this margin to set an if-statement, but when I am running this code, it breaks on the string conversion part, so anyone has an idea??

    Really appreciate any help!


    Link to comment
    Share on other sites

    You'll want to read up on regular expression (regex), it can be used to eliminate certain characters from a character string to parse the data as you so wish.

    Link to comment
    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

    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.