bakadomoko Posted April 16, 2016 Share Posted April 16, 2016 Hi guys,I recently started writing my own script that lets me cook things in Al Kharid. This is what I have so far: case COOKING: RS2Object stove = objects.closest("Range"); inventory.getItems()[2].interact("Use"); sleep(random(200,300)); stove.interact(); if(getDialogues().isPendingOption()){ RS2Widget range = getWidgets().get(307, 162); if(range.isVisible()){ range.interact("Cook all"); sleep(10000); I have no idea what Widgets are but I tried following this guy's advice: http://osbot.org/forum/topic/77995-how-to-right-click-select-cook-all/ I tried following his code but all this does is keep using my trout on the stove. When I use the item on the stove, the dialogue box changes and a picture of the food i'm trying to cook shows up. I need to right click the picture of the food in the dialogue box and then hit "Cook all".Thanks ahead of time for your help!! Quote Link to comment Share on other sites More sharing options...
DragonAlpha Posted April 16, 2016 Share Posted April 16, 2016 (edited) Thanks ahead of time for your help!! This line needs changing: getWidgets().get(307, 162); Use Options, Widget debugger, hover over the Fish in the cooking dialogue, and it will tell you the correct numbers to use. Also after stove.interact(), you need to wait(sleep) until the Dialogue comes up. For now, just put sleep(5000); since you are new and just testing. stove.interact(); sleep(5000); Eventually you can look into "Conditional Sleeping". This means, your script won't just sleep for 5 seconds, it will sleep until something happens, example: sleepUntil(no more raw fish left) instead of sleep(10000) Don't worry about that for now. Edited April 16, 2016 by DragonAlpha Quote Link to comment Share on other sites More sharing options...
bakadomoko Posted April 16, 2016 Author Share Posted April 16, 2016 (edited) This line needs changing: getWidgets().get(307, 162); Use Options, Widget debugger, hover over the Fish in the cooking dialogue, and it will tell you the correct numbers to use. Also after stove.interact(), you need to wait(sleep) until the Dialogue comes up. For now, just put sleep(5000); since you are new and just testing. stove.interact(); sleep(5000); I'm not sure which number to use or how to format it: I got the values 307 and 162 from the first line in green: I would really appreciate if you could explain to me what a Widget and Widget child are so I can conceptually understand what the script is trying to do. Thanks so much!! Edited April 16, 2016 by bakadomoko Quote Link to comment Share on other sites More sharing options...
Explv Posted April 16, 2016 Share Posted April 16, 2016 (edited) I'm not sure which number to use or how to format it: I got the values 307 and 162 from the first line in green: widget 1.PNG widget 2.png I would really appreciate if you could explain to me what a Widget and Widget child are so I can conceptually understand what the script is trying to do. Thanks so much!! Note: the text must be exact (case as well). It is "Cook All" not "Cook all" It is also better practice to find widgets using text when you can: RS2Widget troutWidget = getWidgets().getWidgetContainingText("Raw trout"); if(troutWidget != null) troutWidget.interact("Cook All"); Edited April 16, 2016 by Explv Quote Link to comment Share on other sites More sharing options...
bakadomoko Posted April 16, 2016 Author Share Posted April 16, 2016 (edited) I changed the code to what you had: case COOKING: RS2Object stove = objects.closest("Range"); inventory.getItems()[2].interact("Use"); sleep(random(200,300)); stove.interact(); if(getDialogues().isPendingOption()){ RS2Widget troutWidget = getWidgets().getWidgetContainingText("Raw trout"); if(troutWidget != null) troutWidget.interact("Cook All");{ sleep(10000); } } And it keep selecting the first trout in my inventory, clicking on the stove, and repeats this again and again. Edited April 16, 2016 by bakadomoko Quote Link to comment Share on other sites More sharing options...
DragonAlpha Posted April 16, 2016 Share Posted April 16, 2016 I'm not sure which number to use or how to format it: I got the values 307 and 162 from the first line in green: widget 1.PNG widget 2.png I would really appreciate if you could explain to me what a Widget and Widget child are so I can conceptually understand what the script is trying to do. Thanks so much!! The box around the trout is GREEN, so you look at the green numbers. 307, 2 not 307, 162 Got it? I changed the code to what you had: case COOKING: RS2Object stove = objects.closest("Range"); inventory.getItems()[2].interact("Use"); sleep(random(200,300)); stove.interact(); if(getDialogues().isPendingOption()){ RS2Widget troutWidget = getWidgets().getWidgetContainingText("Raw trout"); if(troutWidget != null) troutWidget.interact("Cook All");{ sleep(10000); } } And it keep selecting the first trout in my inventory, clicking on the stove, and repeats this again and again. You didn't add the sleep like I said. I told you how to fix this in my first reply. Quote Link to comment Share on other sites More sharing options...
bakadomoko Posted April 16, 2016 Author Share Posted April 16, 2016 Thank you so much for your help, I finally managed to fix the problem! Sorry for the repeats, I literally just started coding today so a lot of things are confusing. 1 Quote Link to comment Share on other sites More sharing options...