Jump to content

DexCutter - F2P Draynor Woodcutting Script | Woodcutting Guild Mage Trees


Dextrell

Recommended Posts

Hello everyone this is my first script. 

I'd love to grab some feedback and any progress pictures you guys post would greatly help!

This bot supports all trees around draynor village up to yew trees!

Make sure to start the bot in lumbridge or draynor to get it running for all the other trees!

If you select Magic Trees please be within the woodcutting guild!

Source Code

  Reveal hidden contents

Media

  Reveal hidden contents

 

Jar Download

  Reveal hidden contents

 

Edited by Dextrell
Update fixing a bug with willows
Link to comment
Share on other sites

 

1. Put the image in resources so that a network request is not needed then use SystemIO to get thz. There is no guarantee that the hosting service won't delete your image randomly. Refer to the link below for a more concise tutorial. 


RS2Object treeObject = getObjects().closest(tree.getObjectId());

			if (treeObject == null) {
				this.log("Yew tree is null....");

			}
			log("does it contain tree obj? " + treeArea.contains(treeObject));

 

2. Use the filter API. This can be simplified to something like
```
RS2Object treeObject = getObjects().closest(rs2Object -> rs2Object.getId() == tree.getObjectId() && treeArea.contains(rs2Object);
```

This will ensure tree interactions are only done on trees of a certain type (regular, oak, willow, ect.) and are in the designated area.

 

 

3. The Paint and GUI are crammed in the the Script class its hard to read. Consider splitting these up into individual classes. You can designate a painter class by having it implement Painter. Then in onStart calling

getBot().addPainter(<paint instance>)

Make sure to remove this in onStop with 

getBot().removePainter(<same instance as above>)

Otherwise the paint may not get cleaned up if the script crashes/exits. 


4. You don't need to call this if you are intending to immediately interact with the object. The interaction will do this if the object is not on screen. 

if (getCamera().toEntity(treeObject))






Its a great first attempt. Ill take a look at the gui later. 

Edited by yfoo
  • Heart 1
Link to comment
Share on other sites

As for the GUI error

public void onStart() {
		log("Initializing Script....");
		frame = new JFrame("DexCutter");
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.setBounds(50, 50, 400, 400);
		frame.setVisible(true); //<<<<<<<<<<<<<<<<<
...


Move 

frame.setVisible(true);


to the end of onStart(). It is set to visible before al the other components are added to the panel. 

  • Heart 1
Link to comment
Share on other sites

  On 6/29/2024 at 10:20 PM, yfoo said:
 

1. Put the image in resources so that a network request is not needed then use SystemIO to get thz. There is no guarantee that the hosting service won't delete your image randomly. Refer to the link below for a more concise tutorial. 


RS2Object treeObject = getObjects().closest(tree.getObjectId());

			if (treeObject == null) {
				this.log("Yew tree is null....");

			}
			log("does it contain tree obj? " + treeArea.contains(treeObject));

 

2. Use the filter API. This can be simplified to something like
```
RS2Object treeObject = getObjects().closest(rs2Object -> rs2Object.getId() == tree.getObjectId() && treeArea.contains(rs2Object);
```

This will ensure tree interactions are only done on trees of a certain type (regular, oak, willow, ect.) and are in the designated area.

 

 

3. The Paint and GUI are crammed in the the Script class its hard to read. Consider splitting these up into individual classes. You can designate a painter class by having it implement Painter. Then in onStart calling

getBot().addPainter(<paint instance>)

Make sure to remove this in onStop with 

getBot().removePainter(<same instance as above>)

Otherwise the paint may not get cleaned up if the script crashes/exits. 


4. You don't need to call this if you are intending to immediately interact with the object. The interaction will do this if the object is not on screen. 

if (getCamera().toEntity(treeObject))






Its a great first attempt. Ill take a look at the gui later. 

Expand  

Thank you so much for the useful insight I'll make those changes!

You're right about the painter thank you so much for the tips!

Link to comment
Share on other sites

  • 1 month later...
  On 6/29/2024 at 10:20 PM, yfoo said:
 

1. Put the image in resources so that a network request is not needed then use SystemIO to get thz. There is no guarantee that the hosting service won't delete your image randomly. Refer to the link below for a more concise tutorial. 


RS2Object treeObject = getObjects().closest(tree.getObjectId());

			if (treeObject == null) {
				this.log("Yew tree is null....");

			}
			log("does it contain tree obj? " + treeArea.contains(treeObject));

 

2. Use the filter API. This can be simplified to something like
```
RS2Object treeObject = getObjects().closest(rs2Object -> rs2Object.getId() == tree.getObjectId() && treeArea.contains(rs2Object);
```

This will ensure tree interactions are only done on trees of a certain type (regular, oak, willow, ect.) and are in the designated area.

 

 

3. The Paint and GUI are crammed in the the Script class its hard to read. Consider splitting these up into individual classes. You can designate a painter class by having it implement Painter. Then in onStart calling

getBot().addPainter(<paint instance>)

Make sure to remove this in onStop with 

getBot().removePainter(<same instance as above>)

Otherwise the paint may not get cleaned up if the script crashes/exits. 


4. You don't need to call this if you are intending to immediately interact with the object. The interaction will do this if the object is not on screen. 

if (getCamera().toEntity(treeObject))






Its a great first attempt. Ill take a look at the gui later. 

Expand  

I've tried loading the image as a resource countless of times i set a "res" folder as a resource my file structure is the following

(I made sure the res folder was set as a resource folder)

DexCutter

      -> src

               com.dexcutter <- code goes here

     -> res

             img.png

It will always be null I've tried loading it many different ways even did DexCutter.class.getResourceAsStream  

The only thing I can consider doing is having a downloader that gets the image online and puts it in the data folder.

try {

backgroundImage = ImageIO.read(getScriptResourceAsStream("img.png"));

} catch (IOException e) {

log(e);

}

Edited by Dextrell
Link to comment
Share on other sites

  • Dextrell changed the title to DexCutter - F2P Draynor Woodcutting Script | Woodcutting Guild Mage Trees
  On 8/23/2024 at 2:20 PM, Dextrell said:

I've tried loading the image as a resource countless of times i set a "res" folder as a resource my file structure is the following

(I made sure the res folder was set as a resource folder)

DexCutter

      -> src

               com.dexcutter <- code goes here

     -> res

             img.png

It will always be null I've tried loading it many different ways even did DexCutter.class.getResourceAsStream  

The only thing I can consider doing is having a downloader that gets the image online and puts it in the data folder.

try {

backgroundImage = ImageIO.read(getScriptResourceAsStream("img.png"));

} catch (IOException e) {

log(e);

}

Expand  

Path is wrong. its in /res, and getScriptResourceAsStream("img.png") does not have /res in it. 

Link to comment
Share on other sites

  On 8/24/2024 at 12:42 AM, yfoo said:

Path is wrong. its in /res, and getScriptResourceAsStream("img.png") does not have /res in it. 

Expand  

I've done that as well it doesn't seem to find the file but when I extracted the jar it doesnt place the images in a res folder it only contains it within the root folder of that jar

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