Jump to content

Script crashing becouse of widget


WSSL

Recommended Posts

My script keeps crashing when i try to interact with a widget.

I've tried putting in as action: "Make","Make Gold ring", "Make <col=ff9040>Gold ring</col>"

In the console:

Main.onStart(Main.java:37)

image.thumb.png.b59e81baf9763664cfb5724437c903d9.png

44: objects.closest("Furnace").interact("Smelt");
45: RS2Widget furnacewidget = widgets.get(446,7);
46: sleep(2000);
47: furnacewidget.interact("Make");
Edited by WSSL
Link to comment
Share on other sites

You should always nullcheck and you should avoid using regular sleeps.

In your example you click on the furnace and in that time your character will still be moving (and 2sec is probably too short, you should use conditional sleeps here) and the interface isnt even open but you already get the widget. But since the interface isnt open you will get null and after your 2sec sleep you will try to interact with a widget thats null.

Also if you just try to execute a bunch of orders in a row like you do your script breaks the moment anything doesnt work as it should (lagg for example).

Much better would do doing something like:

if widget == null (means interface isnt open)

-> interact with furnace -> conditional sleep until widget != null (so interface is open)

else if widget != null (interface open)

-> interact with widget

So in the first loop your script would interact with the furnace and sleep until the interface is open and in the next loop it will interact with the widget.

 

Take a look at this tutorial:

 

  • Like 3
Link to comment
Share on other sites

Get used to writing scripts like this :)

if(furnancewidget != null){

furnancewidget.interact();

}

It doesn't mean it will make interactions work everytime, but it will save you from crashes. Also one thing I use myself, don't be afraid to use Mouse(); class, you dont have to use Widgets all the time, in this case Mouse(); would work too and it would keep on working if Jagex decide to change widget IDs which they do time to time

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