Jump to content

[Beginner] Progressive Wc-script, getAxes() method design questions


t0r3

Recommended Posts

Hey :)

1)

Better to have 

getBank().depositAll(axes)

in

if (canGetSteelAxe && axeInBank) {}

or in

boolean axeInBank = getBank().contains(axes -> axes.getName().endsWith("axe")) && getBank().depositAll(axes);

like I already do?

Thinking having it in each of the if's would require less from the cpu, rather than calling it every single time I'm using my getAxes() method?

EDIT: Had to change things up, so that bot wouldn't withdraw and deposit axe every single time before proceeding.

2)

Would it be better to include ex. 

getBank().withdraw("Steel axe", 1);

 in 

boolean canGetSteelAxe = (wcLvl > 6 && wcLvl < 21) && getBank().contains(axes);

, and just leave it with 

getBank().depositAll(axes);
log("Withdrawing Steel axe");

 ? :)

 

...Sorry if the question is confusing hahah.

 

getAxes() code :

private void getAxes() {

     int wcLvl = getSkills().getStatic(Skill.WOODCUTTING);

     boolean canGetSteelAxe = (wcLvl > 6 && wcLvl < 21) && getBank().contains(axes) && !getInventory().contains("Steel axe");
     boolean canGetMithrilAxe = (wcLvl >= 21 && wcLvl < 31) && getBank().contains(axes) && !getInventory().contains("Mithril axe");
     boolean canGetAdamantAxe = (wcLvl >= 31 && wcLvl < 41) && getBank().contains(axes) && !getInventory().contains("Adamant axe");
     boolean canGetRuneAxe = wcLvl >= 41 && getBank().contains(axes) && !getInventory().contains("Rune axe");

    boolean axeInBank = getBank().contains(axes -> axes.getName().endsWith("axe"));

    if (canGetSteelAxe && axeInBank) {

        getBank().depositAll(axes);
        log("Withdrawing Steel axe");
        getBank().withdraw("Steel axe", 1);
    }

    if (canGetMithrilAxe && axeInBank) {

        getBank().depositAll(axes);
        log("Withdrawing Mithril axe");
        getBank().withdraw("Mithril axe", 1);
    }

    if (canGetAdamantAxe && axeInBank) {

        getBank().depositAll(axes);
        log("Withdrawing Adamant axe");
        getBank().withdraw("Adamant axe", 1);
    }

    if (canGetRuneAxe && axeInBank) {

        getBank().depositAll(axes);
        log("Withdrawing Rune axe");
        getBank().withdraw("Rune axe", 1);
    }
}
Edited by t0r3
Link to comment
Share on other sites

3 minutes ago, t0r3 said:

hahah :D No one use black axe ? Got any suggestions though? : )

I do.. ? lol but on a serious note as I said before I personally have not used booleans so I would write something like:

If (wcLvl > 21 && wcLvl < 31) {

getWalking.webWalk(bank)

getbank.open

deposit steelaxe

withdraw mithrilaxe

Wrote on phone so yeah.. 

Link to comment
Share on other sites

13 minutes ago, Imthabawse said:

I do.. ? lol but on a serious note as I said before I personally have not used booleans so I would write something like:

If (wcLvl > 21 && wcLvl < 31) {

getWalking.webWalk(bank)

getbank.open

deposit steelaxe

withdraw mithrilaxe

Wrote on phone so yeah.. 

Yeah that would work I think, but I don't want to do that in the middle of cutting wood. Wanna wait till banking :)

15 minutes ago, HeyImJamie said:

I'd suggest looking at Enums. :)

Thanks! Any examples, and in relation what? :D

Link to comment
Share on other sites

8 minutes ago, Imthabawse said:

@t0r3 in that case you could add to if (wcLvl > 21 && wcLvl < 31 && getInventory.isFull) {

walk.bank

Etc..

I have this in my banking method :) Might have to change some stuff tho

private void needToBank() throws InterruptedException {

    boolean axeInInventory = getInventory().contains(axes -> axes.getName().endsWith("axe"));

    if (!Banks.LUMBRIDGE_UPPER.contains(myPosition())) {

        getWalking().webWalk(Banks.LUMBRIDGE_UPPER);

    }  if (getInventory().isEmpty() || !axeInInventory){

        getBank().open();

        SleepEasy.sleepUntil(() -> getBank().isOpen(), 18000);

        if (getBank().contains(axes)) {

            getAxes();
        }
    }

    if (getInventory().isFull()) {

        getBank().open();

        SleepEasy.sleepUntil(() -> getBank().isOpen(), 14000);

        if (getBank().isOpen() && getInventory().contains(logs -> logs.getName().endsWith("logs"))) {

            getBank().depositAllExcept(axes);
        }

        if (getBank().contains(axes)) {

            getAxes();
        }
    }
}
Edited by t0r3
Link to comment
Share on other sites

8 minutes ago, Imthabawse said:

Wouldnt it try to keep getting an axe out of the bank after wcLvl >= 41 "Rune axe"? Have you tested this?

Yeah maybe. No, haven't tested it. But when using the other axes, it already has the desired axe in inventory and is not stuck trying to withdraw/deposit other axes. So guess that it still would work. Could set it to == 41 probably idk :o u making a progressive script too? hehe

EDIT: yes, it got stuck lol. 

changed it to ;

boolean canGetMithrilAxe = (wcLvl >= 21 && wcLvl < 31) && getBank().contains(axes);
boolean canGetAdamantAxe = (wcLvl >= 31 && wcLvl < 41) && getBank().contains(axes);
Edited by t0r3
Link to comment
Share on other sites

2 minutes ago, Imthabawse said:

Actually id use that to get all axes.. ex:

If(wcLvl == 21) {

get Mithril axe 

And no i'm not making a progressive script I just write scripts for tasks I dont wanna do lol

Yeah, but what if the script starts at lvl 24 and has a steel axe equipped? Then it would not withdraw another axe before reaching lvl 31? :D

Link to comment
Share on other sites

14 minutes ago, Imthabawse said:

Yeah true guess thatd only be good from lvl 1 ?

yeah ?  

Discovered it would always deposit the current axe before withdrawing it again, each time banking. Changed it to;

boolean canGetSteelAxe = (wcLvl > 6 && wcLvl < 21) && getBank().contains(axes) && !getInventory().contains("Steel axe");

so that it will only get the steel axe when it is not in inventory :)

Also moved 

getBank().depositAll(axes);

out of

boolean axeInBank

into

if (canGetSteelAxe && axeInBank)

aaand now it works :) lol, always something wrong

Changed it in the OP too.

 

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