Zompies 20 Share Posted October 26, 2015 Can someone please explain how to use widgets because i'm having trouble with this. I have WidgetChild cookInterface = getWidgets().getWidgetChild(317, 2); Something along those lines and i have in if statement. if(cookInterface.isVisible){cookInterface.interact("Cook all");} But I get a null pointer exception. I am not sure how to detect if the widget is on the screen can someone please help? Link to comment Share on other sites More sharing options...
DefCon 121 Share Posted October 26, 2015 (edited) The problem is most likely that you're trying to check if the widget is visible before it is open.. thus making cookInterface null. Edited October 26, 2015 by DefCon Link to comment Share on other sites More sharing options...
Zompies 20 Author Share Posted October 27, 2015 The problem is most likely that you're trying to check if the widget is visible before it is open.. thus making cookInterface null. i have and != null but still its messing up Link to comment Share on other sites More sharing options...
Ales 2 Share Posted October 27, 2015 (edited) You should have two widgets to avoid null exception. Just my thoughts.. Edited October 27, 2015 by Ales Link to comment Share on other sites More sharing options...
Dreamlicker 749 Share Posted October 27, 2015 Can someone please explain how to use widgets because i'm having trouble with this. I have WidgetChild cookInterface = getWidgets().getWidgetChild(317, 2); Something along those lines and i have in if statement. if(cookInterface.isVisible){cookInterface.interact("Cook all");} But I get a null pointer exception. I am not sure how to detect if the widget is on the screen can someone please help? if (cookInterface != null && cookInterface.isVisible()) Link to comment Share on other sites More sharing options...
DefCon 121 Share Posted October 27, 2015 (edited) try checking that the parent node isnt null first?.... if(getWidgets().get(317)!=null) WidgetChild cookInterface = getWidgets().getWidgetChild(317, 2); Edited October 27, 2015 by DefCon Link to comment Share on other sites More sharing options...
fomfomfom 0 Share Posted February 13, 2016 Can someone please explain how to use widgets because i'm having trouble with this. I have WidgetChild cookInterface = getWidgets().getWidgetChild(317, 2); Something along those lines and i have in if statement. if(cookInterface.isVisible){cookInterface.interact("Cook all");} But I get a null pointer exception. I am not sure how to detect if the widget is on the screen can someone please help? How did you find the 317 and 2 numbers? I am having a horrible time figuring out how to work with widgets. (I actually want to check for the cooking interface, as well). Link to comment Share on other sites More sharing options...
Pandemic 2469 Share Posted February 13, 2016 How did you find the 317 and 2 numbers? I am having a horrible time figuring out how to work with widgets. (I actually want to check for the cooking interface, as well). Use our widget hover debugger (Tools -> Debug -> Widget Hover or something like that) Link to comment Share on other sites More sharing options...
Recommended Posts