Everything posted by Jake Slang
-
Cooking bot, double click
Check my previous post. I've updated the syntax, it should work now. I made a mistake, I think I just woke up around that time, my bad.. Also,, that rawFoodName (between quotes) was just a parameter/placeholder, you should pass in the full name of the raw fish: Sleep.sleepUntil(() -> !getInventory().contains("Raw tuna"), 120000); Oh, and make sure the timeout is around 2 minutes, or else it'll try cooking again after 5 seconds. If you cook a variety of food you could also do: Sleep.sleepUntil(() -> !getInventory().contains("Raw tuna") && !getInventory().contains("Raw lobster"), 120000);
-
Cooking bot, double click
Something like this: Sleep.sleepUntil(() -> !getInventory().contains("rawFoodName"), 120000); So now your player will sleep until your inventory doesn't contain the given raw food (first parameter), or until the timeout is hit (which is set to 2 minutes now). You have to think about the timeout. I've set it to 2 minutes, because the first parameter will most likely evaluate to false, but you don't want the second parameter to evaluate to true after like 3 seconds, which will loop your script again. This snippet is made because it is shorter and self-explanatory in the way you read it: Let your script sleep until the first given parameter is truthy (thus continue running your script), or until the timeout is hit (thus continue running your script). Timeout is in milliseconds btw.
-
Terrorist Attack in Finland.
I guess this is the right section for posting pointless/unnecessary threads like these.. Are you trying to provoke/make people scared? People die every day.
- [$] JakesChocolateGrinder (v1.1) || F2P MONEY MAKING SCRIPT (UP TO 70K/HOUR) || NO REQUIREMENTS [$]
- ZeFishLooter [GOOD CASH (30k/ph)] [F2P] [NO REQ]
-
Cooking bot, double click
You need a conditional sleep. Now you're just sleeping for 4-5 seconds (which your script uses to cook 3 fishes before looping again). So what you want is: Sleep.sleepUntil(() -> condition, timeout); Now it will sleep until the condition (is true) or the timeout is met. The condition could be till there are no raw fishes left in your inventory. I would give the timeout some absurd number so you'll pretty much only stop cooking when the condition evaluates to true. In order to use this static sleepUntil() method, you should add this snippet under your main class: https://hastebin.com/azusobiyur.java Also check out:
- [$] JakesChocolateGrinder (v1.1) || F2P MONEY MAKING SCRIPT (UP TO 70K/HOUR) || NO REQUIREMENTS [$]
-
Hi, I'm Hez! (New Scripter)
Hey, hey, welcome to OSBot!! I'm also a dev, hope we can all learn from each other.
-
On vacation til next sunday
Have fun! >:D
-
Web Framework for a personal dev portfolio
Laravel integrates everything you need as a Web dev.
- [$] JakesChocolateGrinder (v1.1) || F2P MONEY MAKING SCRIPT (UP TO 70K/HOUR) || NO REQUIREMENTS [$]
-
[$] JakesChocolateGrinder (v1.1) || F2P MONEY MAKING SCRIPT (UP TO 70K/HOUR) || NO REQUIREMENTS [$]
[$] JakesChocolateGrinder (v1.1) [$] Features Cuts chocolate bar into chocolate dust for currently 60k/hour (WARNING: PRICES MAY FLUCTUATE) Banks Logs you out when out of bars Requirements 50k starting cash for buying in the choco bars (preferably a lot more for convenience) A knife (NO PESTLE & MORTAR) Configuring the script Download the .jar file Copy or cut it into your OSBot scripts folder (e.g. C:\users\username\OSBot\Scripts\) Log in on OSBot Refresh the Script Selector (the script should be added now) Instructions You have to start in Varrock East Bank (or it'll webwalk you to it)! Make sure you have a knife and chocolate bar(s) in your inventory/bank Run the script via the Script Selector and let it do its thing >:D Versions v1.0 - Initial release v1.1 - Added paint JakesChocolateGrinder.jar
-
ad wont close
If you have a script running, you can't X it; you have to make sure that the script you're running is either paused or stopped.
-
Code review: Fishing script
Ok, so I even found another bug in here. Once you your inventory is full, it'll execute the bank() method as expected, and when you depositAll(), it'll trigger the canFishShrimps() method, because when you deposit all, your inventory doesn't have that fishing net that it expects.. But since I didn't include an else if statement that conditionally asks if the (getBank().isOpen()) method is true, it would execute the else statement, thus logging out. So in the end refactoring did in fact help. This is my code after listening to @TheWind's advice: import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.script.MethodProvider; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.util.function.BooleanSupplier; @ScriptManifest(author = "Jake Slang", name = "JakesShrimpCatcher", info = "Catches shrimp (and anchovies) in Lumbridge swamp.", version = 0.1, logo = "") public final class JakesShrimpCatcher extends Script { private final Area lumbyFishing = new Area(3240, 3150, 3238, 3145); private final Position lumbyBank = new Position(3208, 3220, 2); Entity fishingSpot = null; @Override public final void onStart() { log("Is there anybody actually reading THIS?!"); } @Override public final int onLoop() throws InterruptedException { if (canFishShrimps()) { fish(); } else { bank(); } return random(200, 300); } @Override public final void onExit() { log("I guess YOU did!"); } private void fish() { if (!lumbyFishing.contains(myPosition())) { getWalking().webWalk(lumbyFishing); } fishingSpot = getNpcs().closest("Fishing spot"); if (fishingSpot != null && fishingSpot.interact("Net")) { sleepConditional(); } } private void sleepConditional() { Sleep.sleepUntil(() -> myPlayer().isAnimating() || !fishingSpot.exists(), 5000); } private void bank() throws InterruptedException { if (getInventory().isFull()) { if (!Banks.LUMBRIDGE_UPPER.contains(myPosition())) { getWalking().webWalk(lumbyBank); } if (!getBank().isOpen()) { getBank().open(); getBank().depositAll(); } else if (getBank().isOpen()) { getBank().depositAll(); } else { stop(true); } } } private boolean canFishShrimps() throws InterruptedException { if (!getInventory().contains("Small fishing net")) { if (!Banks.LUMBRIDGE_UPPER.contains(myPosition())) { getWalking().webWalk(lumbyBank); } if (!getBank().isOpen()) { getBank().open(); getBank().withdraw("Small fishing net", 1); } else if (getBank().isOpen()) { getBank().withdraw("Small fishing net", 1); } else { stop(true); } } return !myPlayer().isAnimating() && !getInventory().isFull(); } } class Sleep extends ConditionalSleep { private final BooleanSupplier condition; public Sleep(final BooleanSupplier condition, final int timeout) { super(timeout); this.condition = condition; } @Override public final boolean condition() throws InterruptedException { return condition.getAsBoolean(); } public static boolean sleepUntil(final BooleanSupplier condition, final int timeout) { return new Sleep(condition, timeout).sleep(); } }
-
Code review: Fishing script
Thanks @TheWind for your comprehensive feedback. I'll read it through tomorrow. Have to get some rest now
-
Code review: Fishing script
Hey, thanks for replying. Do you have any suggestions? What kind of scripts did you write before applying for Scripter 1? Yeah, I specifically grabbed the tile position of the Lumbridge bank, because else it would bug around on banking.
-
Code review: Fishing script
OK, I was just hoping for some remarks on for example my sleep() usage. I think I could do things more efficiently.. If I learn to see these gotchas faster, it'll make me a better programmer overall, really.
-
Code review: Fishing script
Hey, so I just finished writing my first script for learning purposes. I'd like to get some feedback on ways to refactor this logic down a bit more. Here's my code: SPOILER: It basically catches and banks shrimps/anchovies :P import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.script.MethodProvider; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.util.function.BooleanSupplier; @ScriptManifest(author = "Jake Slang", name = "JakesShrimpCatcher", info = "Catches shrimp (and anchovies) in Lumbridge swamp.", version = 0.1, logo = "") public final class JakesShrimpCatcher extends Script { private final Area lumbyFishing = new Area(3240, 3150, 3238, 3145); private final Position lumbyBank = new Position(3208, 3220, 2); @Override public final void onStart() { log("Is there anybody actually reading THIS?!"); } @Override public final int onLoop() throws InterruptedException { if (canFishShrimps()) { fish(); } else { bank(); } return random(200, 300); } @Override public final void onExit() { log("I guess YOU did!"); } private void fish() { if (!lumbyFishing.contains(myPosition())) { getWalking().webWalk(lumbyFishing); } Entity fishingSpot = getNpcs().closest("Fishing spot"); if (fishingSpot != null && fishingSpot.interact("Net")) { sleepConditional(); } } private void sleepConditional() { Entity fishingSpot = getNpcs().closest("Fishing spot"); if (fishingSpot != null && fishingSpot.interact("Net")) { Sleep.sleepUntil(() -> myPlayer().isAnimating() || !fishingSpot.exists(), 5000); log(Sleep.sleepUntil(() -> myPlayer().isAnimating() || !fishingSpot.exists(), 5000)); } } private void bank() throws InterruptedException { if (getInventory().isFull()) { if (!Banks.LUMBRIDGE_UPPER.contains(myPosition())) { getWalking().webWalk(lumbyBank); MethodProvider.sleep(2000); } else if (!getBank().isOpen()) { getBank().open(); getBank().depositAll(); } else { stop(true); } } } private boolean canFishShrimps() throws InterruptedException { if (!getInventory().contains("Small fishing net")) { getWalking().webWalk(lumbyBank); MethodProvider.sleep(2000); getBank().open(); getBank().withdraw("Small fishing net", 1); } return !myPlayer().isAnimating() && !getInventory().isFull(); } } class Sleep extends ConditionalSleep { private final BooleanSupplier condition; public Sleep(final BooleanSupplier condition, final int timeout) { super(timeout); this.condition = condition; } @Override public final boolean condition() throws InterruptedException { return condition.getAsBoolean(); } public static boolean sleepUntil(final BooleanSupplier condition, final int timeout) { return new Sleep(condition, timeout).sleep(); } } Plot twist: It basically catches shrimps/anchovies and banks them :P
-
How do I keep fishing consistently?
Ok, so I don't think my code was necessarily wrong, but I did made some adjustments conform your advice: private final Area lumbyFishing = new Area(3247, 3156, 3244, 3154); public final int onLoop() throws InterruptedException { if (canFishShrimps()) { fish(); } else { bank(); } return random(150, 200); } private void fish() { if (!lumbyFishing.contains(myPosition())) { getWalking().webWalk(lumbyFishing); } Entity fishingSpot = getNpcs().closest("Fishing spot"); if (fishingSpot != null) { if (fishingSpot.interact("Net")) { sleepConditional(); } } } private void sleepConditional() { Entity fishingSpot = getNpcs().closest("Fishing spot"); if (fishingSpot != null && fishingSpot.interact("Net")) { Sleep.sleepUntil(() -> myPlayer().isAnimating() || !fishingSpot.exists(), 5000); log(Sleep.sleepUntil(() -> myPlayer().isAnimating() || !fishingSpot.exists(), 5000)); } } private void bank() { // } private boolean canFishShrimps() { return !myPlayer().isAnimating() && !getInventory().isFull(); } So I think the problem was that I also had to export my Sleep class (which was automatically created on reference) to my Script folder. PS: And I know I can refactor this logic a lot more; I'm on it! :)
-
How do I keep fishing consistently?
Thank each one of you for all your efforts. I'll read through after breakfast
-
How do I keep fishing consistently?
Hey, so I'm pretty new to this, and I have a question.. I'm currently writing a fishing script for fun/learning purposes, and I stumbled upon the fact that my fish() method stops running after achieving a level or when the fishing spot disappears. I know that the script executioner gets called depending on the ms you specify in the onLoop method, and I've also tried adding a while loop, but neither of these methods helped me fix the problem. private void fish() { if (!lumbyFishing.contains(myPosition())) { getWalking().webWalk(lumbyFishing); } Entity fishingSpot = getNpcs().closest("Fishing spot"); while (fishingSpot.exists()) { if (fishingSpot != null && fishingSpot.interact("Net")) { new Sleep(() -> myPlayer().isAnimating() || !fishingSpot.exists(), 5000).sleep(); } } } SO my question to you guys was: What is wrong with my code? Thanks in advance.
-
Auto switcher
Just follow the instructions on the site. You basically have to 'Get Mouse Position & Add Action' (keybind) on the desired spots. Then you start the 'Script Execution' by pressing another keybind. Here is a showcase on how to set it up:
-
Auto switcher
This works for me: https://www.murgee.com/auto-mouse-click/
- Hi
-
Hi
German, why? I have lots of Dutch friends if you were wondering :P