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
  • Widget call returns null even if it isn't null!


    Cardozz

    Recommended Posts

    Double check the widget parent and child ID, and if they're correct you can try getWidgets().getWidget(84).getChild(26) (but I don't think that'll make a difference).

     

    Just curious... not sure it'll help try getting the 84 widget and null checking it and then grab the child... tho..m getChild should throw an error then shouldn't it... hmm

     

    So i just found out that if i run the script without the widget child visible (it opens the widget with the child in it correctly) it returns FALSE

     

    When i run the script with the widget child visible (the widget with the child already open) it returns TRUE, meaning that the code executed correctly

     

     

    Now that is weird XD

    Link to comment
    Share on other sites

    So i just found out that if i run the script without the widget child visible (it opens the widget with the child in it correctly) it returns FALSE

     

    When i run the script with the widget child visible (the widget with the child already open) it returns TRUE, meaning that the code executed correctly

     

     

    Now that is weird XD

    Are you grabbing the widget before your script opens it? That would explain the issue

    Link to comment
    Share on other sites

    I have quadruple checked the widget child ID. It worked before with the SAME id, but since i ripped the nested code apart (it's correct, no flaws) it needs like 5 loops to see that the child is not null.

     

    Oh and i already did that man, i got the above error with getWidgets().getWidget(84).getChild(26).

     

     

    If it worked before and doesn't now, it probably has to do with your code, pastebin the whole method surrounding it.

    Also, what are you returning in your onLoop? It takes some time for the widgets to update (~600ms or so).

    Link to comment
    Share on other sites

    Are you grabbing the widget before your script opens it? That would explain the issue

    I indeed just found out that this could be an issue. I put all the variables in the first lines of the method. Which means when the method is called, the widget variable will be null. Though i found it weird but this seems to be the issue (grabbing the child early means that it holds on to the fact that it was invisible at that time, even when it's visible later on.

     

    If it worked before and doesn't now, it probably has to do with your code, pastebin the whole method surrounding it.

    Also, what are you returning in your onLoop? It takes some time for the widgets to update (~600ms or so).

    I also thought about this. So i waited 2 seconds before continuing the code, and tthen i made it 5 secons. Nothing changed. But the above explanation might be the issue!

    Link to comment
    Share on other sites

    I indeed just found out that this could be an issue. I put all the variables in the first lines of the method. Which means when the method is called, the widget variable will be null. Though i found it weird but this seems to be the issue (grabbing the child early means that it holds on to the fact that it was invisible at that time, even when it's visible later on.

     

    I also thought about this. So i waited 2 seconds before continuing the code, and tthen i made it 5 secons. Nothing changed. But the above explanation might be the issue!

    The widget grabs all data initially. It does not update each time a method is called on it. Tho an update method might be nice :P

    Link to comment
    Share on other sites

    Thanks @Hopewelljnj and @Pandemic,, IT WORKS NOW!!!

     

    all i had to do was NOT call the widgets on the call of the method (which makes the variable store the state of the widget on call, they don't seem to update when you call them later on).

     

    Good lesson learned :). Never knew that widget variables held onto the state of the widget. I thought they just stored the widget ID's without "null" or "not null" state.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • 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.