Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • GGCutter - A WIP to learn from.


    GGWP

    Recommended Posts

    Hey there! 

    I recently started to learn how to script while also having a bit of java knowledge(although little) and I wrote my first script.

     

    I wish to build my foundations on this script and then start doing other scripts. I appreciate every suggestion and feedback.

     

    It's a simple WC script that cuts wood first at lumbridge, once it reaches 30 it will go cut willows at draynor. At 65 it will go cut yews.

     

    Current features:

    Worldhop if there are no more trees

    Switches axes if reached required level

    Progressive

    Antiban?

    Normal trees-Oaks-Willows-Yews

     

    Possible future features:

    GE api price lookup

    Mouse movement more realism

    a fishing portion with progression

    Optimized code

    More areas

    Random calculate which area to take, setup F2P areas and P2P+F2P areas.

    New paint 

    Signature with stats

    Firemaking?

     

    Feel free to give out suggestions on how to improve script quality.

    Also please explain why it's better if you have the time.

     

    Compiled version here:

    https://dreambot.org/forums/index.php/topic/10613-ggcutter/

     

     

    Source:

     

     

     

     

    Progs:

     

     

    JykCvTm.png

     

    5YbVhku.png

     

    WPtOwKR.png

     

     

     

     

    Link to comment
    Share on other sites

    Thanks for putting this up! One thing I noticed that I do differently (not necessarily better) is how I handle not starting the script until the start button is clicked in the GUI. Instead of using a boolean variable (startScript in your case) and setting it to true when the start button is clicked in the GUI, you could use a while loop with a sleep until the GUI is not visible. You would want to put the loop after you set the GUI to visible in your main file. Here is an example of what I mean. This example would go after line 69 in your code.

    while (gui.isVisible()) {
        sleep(100);
    }
    

    Doing it this way eliminates the extra variable, and since you already set the GUI to not be visible once the start button is clicked, you don't need any extra code in the gui to make it work. 

     

     

    If you're looking for a potential next step (minor improvements / additional features), I think one thing that would be cool to add would be loading prices dynamically using a GE API. I don't have a link to one, but I thought I saw a post in the scripting forum about one a couple days ago.

     

    The main thing I saw that looked a bit out of place was that you had a few conditionals that looked like they were either the exact same, or almost the exact same at various places throughout the script.. The conditionals that I'm talking about are the ones where you're setting `logXP` and `logprice`, and the ones where you're setting `eAxe` and `currentLog`. The start of the first conditional that sets `logXP` and `logprice` starts on line 147. The start of the first conditional that sets `eAxe` and `currentLog` starts on line 118. They both seemed to have at least one more conditional further down in the script that seemed to be almost the same thing. This probably doesn't create any technical errors with the code, it just makes it harder to read through and maintain. This definitely isn't a huge deal or a high priority change, just something that I think would be helpful to you in the long term.

     

    Thanks again for putting this up. I personally found it very helpful, and I'm sure many other new scripters will as well. Reading through it, I learned a couple of new things that will be very useful in the future. I'm by no means an expert in Java, so I cannot guarantee that the feedback I'm giving is the best way to do things. I personally like as much feedback as I can get, so I try to give the best feedback I can when others ask for it. 

     

    Update: As @@Xephy pointed out below, the method that I described here for not starting the script until the user clicks start in the GUI is sub-par. I'll leave it in for posterity sake, just know that if used it will cause the client to close if the user clicks the "X" on the GUI.

    Link to comment
    Share on other sites

    Thanks for putting this up! One thing I noticed that I do differently (not necessarily better) is how I handle not starting the script until the start button is clicked in the GUI. Instead of using a boolean variable (startScript in your case) and setting it to true when the start button is clicked in the GUI, you could use a while loop with a sleep until the GUI is not visible. You would want to put the loop after you set the GUI to visible in your main file. Here is an example of what I mean. This example would go after line 69 in your code.

    while (gui.isVisible()) {
        sleep(100);
    }
    

    Doing it this way eliminates the extra variable, and since you already set the GUI to not be visible once the start button is clicked, you don't need any extra code in the gui to make it work. 

     

    If you do this, wouldn't it start the script and throw errors if you were to close the gui with the 'X' button?

    Link to comment
    Share on other sites

    You could do it that way, I would prefer to keep that extra variable in there, depends what you prefer to do I suppose

    Yeah, thats just how I learned to do it. It sounds like its definitely not the best way to do it based on Xephys comment.

     

    If you do this, wouldn't it start the script and throw errors if you were to close the gui with the 'X' button?

    Thanks for the headsup, I hadn't actually tried that before so I just tested it out. When I closed the gui with the "X" button it actually closed the client entirely, If it didn't close the client it probably would start the script as you mentioned, so definitely not the best way to do it. Is the best way to do it to use a variable similarly to the way its done here?

    Link to comment
    Share on other sites

    Yeah, thats just how I learned to do it. It sounds like its definitely not the best way to do it based on Xephys comment.

     

    Thanks for the headsup, I hadn't actually tried that before so I just tested it out. When I closed the gui with the "X" button it actually closed the client entirely, If it didn't close the client it probably would start the script as you mentioned, so definitely not the best way to do it. Is the best way to do it to use a variable similarly to the way its done here?

     

    Look at your gui code and it might have something near the top of the constructor that employs an 'exit on close'. I'm not sure what builder you're using, but it should look something like this: "setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);"

     

    Delete / change whatever assigns the close operation and you'll be able to exit it without closing your entire client. It's horridly annoying when SDN scripts have that default anyways. I'd just set it to the "Hide" constant.

    Link to comment
    Share on other sites

    Look at your gui code and it might have something near the top of the constructor that employs an 'exit on close'. I'm not sure what builder you're using, but it should look something like this: "setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);"

     

    Delete / change whatever assigns the close operation and you'll be able to exit it without closing your entire client. It's horridly annoying when SDN scripts have that default anyways. I'd just set it to the "Hide" constant.

    You were right, that's exactly what I had. I changed it to the hide constant and then retested closing the GUI with the "X". It did what you thought it would (started running the script). Thanks again! I appreciate the help!

    Link to comment
    Share on other sites

    You were right, that's exactly what I had. I changed it to the hide constant and then retested closing the GUI with the "X". It did what you thought it would (started running the script). Thanks again! I appreciate the help!

     

    My pleasure :)

    Link to comment
    Share on other sites

    Thanks for putting this up! One thing I noticed that I do differently (not necessarily better) is how I handle not starting the script until the start button is clicked in the GUI. Instead of using a boolean variable (startScript in your case) and setting it to true when the start button is clicked in the GUI, you could use a while loop with a sleep until the GUI is not visible. You would want to put the loop after you set the GUI to visible in your main file. Here is an example of what I mean. This example would go after line 69 in your code.

    while (gui.isVisible()) {
        sleep(100);
    }
    

    Doing it this way eliminates the extra variable, and since you already set the GUI to not be visible once the start button is clicked, you don't need any extra code in the gui to make it work. 

     

     

    If you're looking for a potential next step (minor improvements / additional features), I think one thing that would be cool to add would be loading prices dynamically using a GE API. I don't have a link to one, but I thought I saw a post in the scripting forum about one a couple days ago.

     

    The main thing I saw that looked a bit out of place was that you had a few conditionals that looked like they were either the exact same, or almost the exact same at various places throughout the script.. The conditionals that I'm talking about are the ones where you're setting `logXP` and `logprice`, and the ones where you're setting `eAxe` and `currentLog`. The start of the first conditional that sets `logXP` and `logprice` starts on line 147. The start of the first conditional that sets `eAxe` and `currentLog` starts on line 118. They both seemed to have at least one more conditional further down in the script that seemed to be almost the same thing. This probably doesn't create any technical errors with the code, it just makes it harder to read through and maintain. This definitely isn't a huge deal or a high priority change, just something that I think would be helpful to you in the long term.

     

    Thanks again for putting this up. I personally found it very helpful, and I'm sure many other new scripters will as well. Reading through it, I learned a couple of new things that will be very useful in the future. I'm by no means an expert in Java, so I cannot guarantee that the feedback I'm giving is the best way to do things. I personally like as much feedback as I can get, so I try to give the best feedback I can when others ask for it. 

     

    Update: As @@Xephy pointed out below, the method that I described here for not starting the script until the user clicks start in the GUI is sub-par. I'll leave it in for posterity sake, just know that if used it will cause the client to close if the user clicks the "X" on the GUI.

     

    GE api is a nice feature, i'll add it once the script is a bit more advanced.

     

    The GUI suggestion is great but I sometimes use my script to use login solver  :) (too lazy to write account details) so if it closes or starts the script if I exit it, it would be a tad annoying. In the future I plan to add a few options get like powerchop and/or a noob mode for lvl 3 skillers so they don't go to areas where they might get attacked.

     

    As for the conditionals, script messed up a few times with switching axes(didn't correctly set eAxe  so I eventually copied the text under onLoop and put it under CUT so it would update more. I plan to use a better system using a enum.

     

    I am happy to know my script helped you out  :) .I also appreciate feedback haha

     

    Edit:

     

    updated the script. Should be able to run anywhere and take a axe out of the bank.

    Added oaks, few more areas.

     

    Will soon add a powerchop option and randomization of areas.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.