Jump to content

[New Scriptwriter] Please help! How to "cook all" food?


bakadomoko

Recommended Posts

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

 

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

 

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:

post-220625-0-41369000-1460845535_thumb.png

post-220625-0-87738300-1460845622_thumb.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!!

Edited by bakadomoko
Link to comment
Share on other sites

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:

attachicon.gifwidget 1.PNG

attachicon.gifwidget 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 by Explv
Link to comment
Share on other sites

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

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:

attachicon.gifwidget 1.PNG

attachicon.gifwidget 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.

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