Jump to content

Open Source Oak woodcutter with semi-auto muling


Zor

Recommended Posts

ZzWoodcutter

Status:Working

Download: V1.1

Code:Github

Simple working script to chop logs from 1-15 then Oak logs until ban

  • 1-15 logs 15-ban oak logs
  • Start with 7 questpoints
  • Deposits oak logs at port sarim
  • Muling support at set amount of logs
  • Desktop notifications when it is ready to mule
  • Very informative paint
  • Muling at Draynor bank

 

Future features?

 

Known bugs

can only use bronze axe

 

Guidelines:

Start anywhere,

Equip axe (not mandatory but helpful, has to at least be in inventory)

Expect a ban

Can be started at whatever Woodcutting level

 

Notes:

I would like to thank @Rays for helping me by showing me snippets to help with this and for the idea

I created this script in 24 hours if there are any bugs please report them

 

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

Hi, I didn't fully look at your code but I see so many people doing this recently so I had to say something (bad open source code hurts the community because bad practices are being learned, not saying your code is bad or anything, just in general).

'This' keyword is used mainly for ambiguity.

Example:

public Class Test(){
  private String name;
    
    public Test(String name){
    	this.name = name;
  	}
}

 People lately have been doing 'this.add()' where add() is a function that exists in the class that you're writing in. Don't do this.

  • Like 2
Link to comment
Share on other sites

48 minutes ago, dreameo said:

Hi, I didn't fully look at your code but I see so many people doing this recently so I had to say something (bad open source code hurts the community because bad practices are being learned, not saying your code is bad or anything, just in general).

'This' keyword is used mainly for ambiguity.

Example:


public Class Test(){
  private String name;
    
    public Test(String name){
    	this.name = name;
  	}
}

 People lately have been doing 'this.add()' where add() is a function that exists in the class that you're writing in. Don't do this.

tbh anything with "this" in it was a copy and paste i did a lot of copy and paste for this and then fixing it but ill remove it to help out the community i dont really see how it hurts it though

Edit:Removed this as much as i could

Edited by Zor
  • Like 1
Link to comment
Share on other sites

I would recommend splitting the project into multiple files. It is not easy to read the code when everything is thrown in to 1 file. If you are unsure about using multiple files, then organize your code such that similar methods are close to each other

IMO I would put in this order

  • onStart()
  • onLoop()
  • onExit()
  • onPaint()
  • onMessage() These 5 methods are inherited from Script, and are similar in that sense.
  • bank()
  • mule() and waitForTrade() These 3 are helper methods as they "help" do things in onLoop
  • afk() only sleeps for a bit, why not just replace every afk() call with whatever you had. sleep(random(3000, 8000)) or whatever.

Furthermore this line in onMessage() does not discern between different message types, if a player spams "You get some oak logs" then your oak log cut counter gets incremented.

if(m.getMessage().contains("You get some oak logs")) oaklogscut++;

first check the message type, you only care if it is a game message. See: https://osbot.org/api/org/osbot/rs07/api/ui/Message.html

if(m.getType == Message.MessageType.GAME && m.getMessage().contains("You get some oak logs") oaklogscut++;

Also, what does this do? the timegui variable is never used. You don't need to use a separate thread to track time, do this in onPaint() which already runs on its own thread. I think you already do this, so this snippet does nothing. 

thread = new Thread(){

	                @Override
	                public synchronized void run() {
	                    while (Main.this.isRunning) {
	                        try {
	                            timegui = System.currentTimeMillis() - Main.this.startTime;
	                            this.wait(50);
	                        }
	                        catch (InterruptedException ex) {
	                            Main.this.log((Object)ex);
	                        }
	                    }
	                }
	            };
thread.start();

Finally why is the code indented weirdly. If you are using an ide you can auto-formate the code.

Anyway, good job.

Link to comment
Share on other sites

On 8/15/2018 at 3:08 AM, PayPalMeRSGP said:

Also, what does this do? the timegui variable is never used. You don't need to use a separate thread to track time, do this in onPaint() which already runs on its own thread. I think you already do this, so this snippet does nothing. 


thread = new Thread(){

	                @Override
	                public synchronized void run() {
	                    while (Main.this.isRunning) {
	                        try {
	                            timegui = System.currentTimeMillis() - Main.this.startTime;
	                            this.wait(50);
	                        }
	                        catch (InterruptedException ex) {
	                            Main.this.log((Object)ex);
	                        }
	                    }
	                }
	            };
thread.start();

Finally why is the code indented weirdly. If you are using an ide you can auto-formate the code.

Anyway, good job.

This is probably due to him picking up some things from my source-code; I actually did not know that onPaint() already runs on its own thread.

Also, the "this" keyword which is a bad habit I adapted when first starting out.

Edited by Rays
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...