Jump to content

How to pickup an item in bank when I hit a certain level?


Jeune Padawan

Recommended Posts

Yo. Basically, I'm trying to make a simple woodcutting script where when he's under level 21, he cuts trees with his iron axe and banks them. When he'd hit 21, he'd go at the bank and deposit everything and then, pickup a mithril axe to go back cut trees. At 31, he would go to bank, deposit all, withdraw an adamant axe and go cutting willows. However, I don't really know how to "say" it. It's like I would have needed a "when" statement for when I hit x level...

This is what it looks like right now. I know it is wrong.

6yM9XHt.png

Also, anyone knows why line 64 is underlined? It's pissing me off >_>

Thanks for the help :) 

Link to comment
Share on other sites

Just put another If statement in the OnLoop that checks for your level and what axe to use for that level, ie:

 

// for pre-mith axe, if you're using just iron
if (getSkills.getStatic(Skill.WOODCUTTING) < 21) {
	// PUT REGULAR CODE HERE FOR CHOPPING W/ LESSER AXE
}
 
// example for mith axe                                             
else if (getSkills.getStatic(Skill.WOODCUTTING) >= 21) {                                              
	if (!getInventory.contains("Mithril axe") {
  		getWalking.webWalk(bank);
      	if bank.contains(myPlayer) {
        	if !getBank.isOpen() {
            	getBank.Open();
            }
         	if getBank.contains("Mithril axe") { // not checking if it is in inventory or not because we checked that prior to walking to bank
            	getBank.withdraw("Mithril axe")
            }
          	if getInventory.contains("Mithril axe") {
            	getBank.close();
            }
        }
  	}
  	else {
  		if !tree.contains(myPlayer) {
        	getWalking.webWalk(tree)
        }
      	else {
          // CHOPPING CODE HERE
        }
  	}
}
  
// onwards for the rest of the axes
else if (... >= 31) {}

...and so on.

 

EDITED IN A SAMPLE FOR WITHDRAWING THE AXE, MISREAD OP.

 

**don't copy my code directly, I wrote it here and I'm sure it has formatting and incorrect API use since I did it from memory, but use it as a basis if needed.

Edited by Magarac
Link to comment
Share on other sites

Add a log to see if it throws anything at all for your first if statement, because it could just be a problem with the webwalk

Try making the line getSkills().getStatic(Skill.wc) > 20 rather than >= 21

Also change "Mithril Axe"  to "Mithril axe" as java is case sensitive :)

Edit: change "logs" to "Logs" aswell

and "Chop Down" to "Chop down"

  • Like 1
Link to comment
Share on other sites

16 minutes ago, IHB said:

Add a log to see if it throws anything at all for your first if statement, because it could just be a problem with the webwalk

Try making the line getSkills().getStatic(Skill.wc) > 20 rather than >= 21

Also change "Mithril Axe"  to "Mithril axe" as java is case sensitive :)

Edit: change "logs" to "Logs" aswell

and "Chop Down" to "Chop down"

Logs is toLowerCase(). As for the rest, the Chop Down still works actually

Link to comment
Share on other sites

8 hours ago, Jeune Padawan said:

Yo. Basically, I'm trying to make a simple woodcutting script where when he's under level 21, he cuts trees with his iron axe and banks them. When he'd hit 21, he'd go at the bank and deposit everything and then, pickup a mithril axe to go back cut trees. At 31, he would go to bank, deposit all, withdraw an adamant axe and go cutting willows. However, I don't really know how to "say" it. It's like I would have needed a "when" statement for when I hit x level...

This is what it looks like right now. I know it is wrong.

6yM9XHt.png

Also, anyone knows why line 64 is underlined? It's pissing me off >_>

Thanks for the help :) 

Start by utilizing the boolean return on those method calls, this will make your script run smoother.

if(!bankArea.contains(myPlayer()) webwalk(bankArea)



if(!bank.isOpen())bank.open();

Even using dynamic sleeps is useful too

if(bank.isOpen()){

if(inventory.contains("logs")){

if(bank.depositAll(item -> item.getName().contains("logs"))){

new ConditionalSleep(4500, 500){ //timeout, recheck   so 4500ms is max sleep, check condition every 500ms

//condition method goes here. Returns boolean, if return true the sleeping will stop, if false it will continue to sleep until timeout

}.sleep();

}

}

 

Line 64, Item-> Item.getName()... Change the lambda variable to something like depositAll(it->i.getName().toLowerCase().contains("logs"). You're using a type as a variable name, but shouldn't be the issue. Read this http://stackoverflow.com/questions/1445233/is-it-possible-to-solve-the-a-generic-array-of-t-is-created-for-a-varargs-param

 

 

 

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