-
Posts
65 -
Joined
-
Last visited
-
Feedback
0%
Everything posted by t0r3
-
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); } }
-
[Beginner] Progressive woodcutter script, what can I improve? :)
t0r3 replied to t0r3's topic in Scripting Help
Thanks! Should've tested the script beforehand haha, getAxes(); didn't work ofcourse... Need to test my scripts more before posting haha.. and yeah those booleans makes it cleaner -
[Beginner] Progressive woodcutter script, what can I improve? :)
t0r3 replied to t0r3's topic in Scripting Help
Ok, progressing a bit Making it easier with boolean variables, lambda expressions, and a String for the axes Also used the alternative sleep from explvl's 101 tutorial, although I don't understand how he made it, but how to use it What do you think? Is this ok? What to do next? (Including important parts) EDIIIIT; Need to test my scripts more haha, getAxes(); would'nt work ofc.. removed it -
[Beginner] Progressive woodcutter script, what can I improve? :)
t0r3 replied to t0r3's topic in Scripting Help
Thanks! Yeah I could do that, but probs not necessary though. Could also do getBank().open() instead of these two; as Chris said (did it) Less demanding of the cpu or something, I guess. RS2Object bankBooth = getObjects().closest("Bank booth"); bankBooth.interact("Bank"); -
[Beginner] Progressive woodcutter script, what can I improve? :)
t0r3 replied to t0r3's topic in Scripting Help
@Chris Is something like this example better logic-wise? Also cut out the "Walking" void from before and trying out conditional sleep public class Sleep extends Script { private Area treeArea = new Area(3190, 3250, 3171, 3263); private void chopTree() { RS2Object tree = getObjects().closest("tree"); if (!treeArea.contains(myPosition())) { getWalking().webWalk(treeArea); } else if (tree != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){ tree.interact("Chop down"); new ConditionalSleep(70000) { @Override public boolean condition() { return !myPlayer().isAnimating() && !myPlayer().isMoving(); } }.sleep(); } } private void needToBank() { if (!Banks.LUMBRIDGE_UPPER.contains(myPosition())){ getWalking().webWalk(Banks.LUMBRIDGE_UPPER); } else { RS2Object bankBooth = getObjects().closest("Bank booth"); bankBooth.interact("Bank"); new ConditionalSleep(70000) { @Override public boolean condition() { return getBank().isOpen(); } }.sleep(); getBank().depositAllExcept("Bronze axe"); } } @Override public int onLoop () throws InterruptedException { if (getInventory().isFull()) { needToBank(); } else { chopTree(); } return 1000; } } -
[Beginner] Progressive woodcutter script, what can I improve? :)
t0r3 replied to t0r3's topic in Scripting Help
Ok, so u mean one method for oaks, one for tree's and so on? chopOaks(); chopTrees(); Yeah that would be better down the line, adding willows and yews thanks! -
[Beginner] Progressive woodcutter script, what can I improve? :)
t0r3 replied to t0r3's topic in Scripting Help
Hey How do I use the itemcontainer class to make a list of the axes? Might be not having enough knowledge of java haha, though I am learning from codeacademy.. -
[Beginner] Progressive woodcutter script, what can I improve? :)
t0r3 replied to t0r3's topic in Scripting Help
Hahaha yeah, I'm just changing up the area, the banks, and using lvls for conditions as to what I'm doing not that hard, just takes a bit more time than creating a script for a single task. -
[Beginner] Progressive woodcutter script, what can I improve? :)
t0r3 replied to t0r3's topic in Scripting Help
@Chris Where am I not checking my conditions before proceeding? How do I write a getter function? and what do you mean by changing my logic to " needToBank -> do this, else .... " ? Can you elaborate/make an example? @Imthabawse What do you mean? When I run the script it interacts with the tree and then doesn't interact again till player is not animating and it won't interact again as the player is not moving. It's only the important part of the code, script runs fine -
Hey Title says it all Anything I could improve or change/ problems I might run into? This is the important part of the code private void walk(){ int wcLvl = getSkills().getStatic(Skill.WOODCUTTING); if (getInventory().isEmptyExcept("Bronze axe", "Iron axe", "Steel axe", "Mithril axe", "Adamant axe", "Rune axe") && !treeArea.contains(myPosition()) && wcLvl < 15){ log("Walking to treeArea"); getWalking().webWalk(treeArea); } else if (getInventory().isEmptyExcept("Bronze axe", "Iron axe", "Steel axe", "Mithril axe", "Adamant axe", "Rune axe") && !oakArea.contains(myPosition()) && wcLvl >= 15){ log("Walking to oakArea"); getWalking().webWalk(oakArea); } if (getInventory().isFull() && !Banks.LUMBRIDGE_UPPER.contains(myPosition())){ log("Walking to Bank"); getWalking().webWalk(Banks.LUMBRIDGE_UPPER); } } private void chop() throws InterruptedException{ RS2Object tree = getObjects().closest("Tree"); RS2Object oak = getObjects().closest("Oak"); int wcLvl = getSkills().getStatic(Skill.WOODCUTTING); if (tree != null && !myPlayer().isAnimating() && !myPlayer().isMoving() && wcLvl < 15){ log("Chopping down tree"); tree.interact("Chop down"); } else if (oak != null && !myPlayer().isAnimating() && !myPlayer().isMoving() && wcLvl >=15){ log("Chopping down oak"); oak.interact("Chop down"); sleep(random(600,1500)); getMouse().moveOutsideScreen(); } } private void bank(){ RS2Object bankBooth = getObjects().closest("Bank booth"); if (Banks.LUMBRIDGE_UPPER.contains(myPosition())&& bankBooth != null && !getBank().isOpen()){ log("Interacting with bank"); bankBooth.interact("Bank"); } else if (getBank().isOpen()){ int wcLvl = getSkills().getStatic(Skill.WOODCUTTING); log("Depositing all logs"); getBank().depositAllExcept("Bronze axe", "Iron axe", "Steel axe", "Mithril axe", "Adamant axe", "Rune axe"); if (wcLvl >= 6 && getInventory().contains("Bronze axe", "Iron Axe") && getBank().contains("Steel axe")){ log("Withdrawing Steel axe"); getBank().deposit("Bronze axe",1); getBank().withdraw("Steel axe",1); } if (wcLvl >= 21 && getInventory().contains("Steel axe") && getBank().contains("Mithril axe")){ log("Withdrawing Mithril axe"); getBank().deposit("Steel axe",1); getBank().withdraw("Mithril axe",1); } if (wcLvl >= 31 && getInventory().contains("Mithril axe") && getBank().contains("Adamant axe")){ log("Withdrawing Adamant axe"); getBank().deposit("Mithril axe",1); getBank().withdraw("Adamant axe",1); } } } @Override public int onLoop() throws InterruptedException{ walk(); chop(); bank(); return 1000; } }
-
[Beginner] Trying to run simple miner, it wont even start?
t0r3 replied to t0r3's topic in Scripting Help
Yeah Ended up making this work; @Override public int onLoop() throws InterruptedException { if(!miningArea.contains(myPosition()) || !Banks.LUMBRIDGE_UPPER.contains(myPosition())) { walking(); } if (miningArea.contains(myPosition())) { levelUpWhile(); mining(); } if (Banks.LUMBRIDGE_UPPER.contains(myPosition())){ banking(); } return 1000; } Tried putting else in front of if (miningArea.contains(myPosition())) Why won't this work? ------------------------------------------------------------------------------------------------------------------------------------- Even though, - could just this work? The conditions for the different methods are already set in each one. Am I wrong? @Override public int onLoop() throws InterruptedException { if(myPlayer.exists()) { walking(); levelUpWhile(); mining(); banking(); } return 1000; } Thanks for being so helpful I know I'm asking many questions haha getting really into it -
[Beginner] Trying to run simple miner, it wont even start?
t0r3 replied to t0r3's topic in Scripting Help
@Script Kid @Xx pk xX The script won't do anything after walking to miningSpot Any suggestions? -
[Beginner] Trying to run simple miner, it wont even start?
t0r3 replied to t0r3's topic in Scripting Help
Thanks Ah, yeah I put all the way up there because I use it both in; private void levelUpWhile() { and, private void mining() throws InterruptedException { This is completely wrong? Put in both methods now, for reference Thanks! Yeah I realize this now hahah -
[Beginner] Trying to run simple miner, it wont even start?
t0r3 replied to t0r3's topic in Scripting Help
Yeah I have the ScriptManifest up, able to locate it, click run and then it just doesnt do anything. When I click the Start button after choosing my script nothing happens. It doesn't even shift from the green play button to pause and stop button options.. -
Hey It's me again Have a problem with my miner, - tried writing it different from what I'm used to; Tried using private voids and then putting them into onLoop. What can I improve and what is making my script not runnable? public class LSCopperMiner extends Script { private Area miningArea = new Area( 3228, 3145, 3229, 3145); private void walking(){ if (getInventory().isEmptyExcept("Bronze pickaxe","Iron pickaxe","Steel pickaxe", "Mithril pickaxe","Adamant pickaxe","Rune pickaxe" ) && !miningArea.contains(myPosition())){ log("Inventory is empty and miningArea does not contain my position, walking to mining area"); getWalking().webWalk(miningArea); } else if(getInventory().isFull() && !Banks.LUMBRIDGE_UPPER.contains(myPosition())) { log("Inventory is full, walking to LBank"); getWalking().webWalk(Banks.LUMBRIDGE_UPPER); } } private RS2Object copperRocks = getObjects().closest(7484,7453); private void levelUpWhile() { while (getDialogues().isPendingContinuation()){ if(getDialogues().clickContinue()){ log("Interacting with copperRocks again"); copperRocks.interact("Mine"); } } } private void mining() throws InterruptedException { if(copperRocks != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){ log("Interacting with copperRocks"); copperRocks.interact("Mine"); log("Sleeping a bit before 'going afk'"); sleep(random(1000,1400)); log("Moving mouse outside of screen,'going afk'"); getMouse().moveOutsideScreen(); } } private void banking() throws InterruptedException { RS2Object bankBooth = getObjects().closest("Bank booth"); if(!getBank().isOpen() && bankBooth != null && Banks.LUMBRIDGE_UPPER.contains(myPosition())) { log("In LBank and Bank is not open, interacting with Bank"); bankBooth.interact("Bank"); log("Sleeping for 1.5-2.5 sec to avoid interacting with bank again"); sleep(random(1500, 2500)); } if(getBank().isOpen()) { log("Bank is open, depositing everything except pickaxes"); getBank().depositAllExcept("Bronze pickaxe","Iron pickaxe","Steel pickaxe", "Mithril pickaxe","Adamant pickaxe","Rune pickaxe"); } } @Override public int onLoop() throws InterruptedException { if(!miningArea.contains(myPosition()) || !Banks.LUMBRIDGE_UPPER.contains(myPosition())) { walking(); } else if(miningArea.contains(myPosition())){ levelUpWhile(); mining(); banking(); } return 1000; } }
-
@HeyImJamie @Czar Got it working! Now paint shows how many shrimps and how many anchovies I caught private int shrimpCount; private int anchoviesCount; public void onMessage(Message m) { if (m.getMessage().contains("You catch some shrimps.")) { shrimpCount++; } else if (m.getMessage().contains("You catch some anchovies.")) { anchoviesCount++; } } Thank you so much! This is fun
- 4 replies
-
- 2
-
-
- beginner
- scripting help
-
(and 2 more)
Tagged with:
-
Hey, thanks! I like how many of the main scripters here are so friendly in this community put it like this ; public void onMessage(Message m) { if (getChatbox().getMessages()) { fishCount++; } } I need to have a message type first in the parameters for getMessages, - what messagetype is the string "You caught some shrimp/anchovies"? Sry if it is obvious haha
- 4 replies
-
- beginner
- scripting help
-
(and 2 more)
Tagged with:
-
Got this to work : // Fishing code NPC fishingSpot = getNpcs().closest("Fishing spot"); while (getDialogues().isPendingContinuation()){ if(getDialogues().clickContinue()){ log("Interacting with fishingSpot again"); fishingSpot.interact("Net"); } } if(fishingSpot != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){ log("Interacting with fishingSpot"); fishingSpot.interact("Net"); I put the While loop first, so that it checks before fishing. If no dialogue option it would just skip it and do usual fishing routine. I think. Why are you using ' .exists ' though, instead of ' fishingSpot != null? It's not the same? Thanks for helping
-
Thank you so much, helping me alot! Guessing I could use this for questing too? Might be a better method though idk As for sleep, I am just using ' sleep(random()); ' at the moment, not used to conditional sleep yet. Put it in like this, - what do you think? // Fishing code NPC fishingSpot = getNpcs().closest("Fishing spot"); if(fishingSpot != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){ while (getDialogues().isPendingContinuation()){ log("Leveled up, clicking continue"); getDialogues().clickContinue(); if(getDialogues().clickContinue()){ log("Interacting with fishingSpot again"); fishingSpot.interact("Net"); } } log("Interacting with fishingSpot"); fishingSpot.interact("Net"); Is it possible to do this without ' if ' after clicking continue, - and also what type is ' getDialogues ' ? I want to declare a variable called Continueing Sry, am noob. Thanks EDIT: - This might not work as myPlayer(); would still be isAnimating(); before going idle, then it would just fish again, making this pointless haha...hm. Should I put it somewhere else maybe? - Tested it again, aaand now my log just confirmed it clicking continue over and over again before going idle hmm
-
Hey Started learning how to script a few days ago, and I am now in need of some help I know how to display for how long the script has been running / and how many levels I have gained. How would I go about counting, logging and displaying f.ex amount of logs chopped since I started the script? - what code could I use? Thanks
- 4 replies
-
- beginner
- scripting help
-
(and 2 more)
Tagged with:
-
ahok What about when I am depositing items into bank? I use getBank.deposit for this. Does getBank have anything to do with widgets? and also, the fishing version of this would be using NPC instead of RS2Object - and getNPC instead of getObject aaand, got any idea s to how I would make my fishingscript interact based on the condition that a message like leveling up is deployed on the screen? Just so that it wont wait till going idle before interacting with the fishing spot again --> getMessages? Thanks!