Jump to content

ultraswagger

Members
  • Posts

    5
  • Joined

  • Last visited

  • Feedback

    0%

Profile Information

  • Gender
    Male

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

ultraswagger's Achievements

Newbie

Newbie (1/10)

0

Reputation

  1. Turns out this was the issue , getInventory.onlyContains was returning True when my inventory was empty. Looks like I didn't look at it thoroughly enough since the api for it does say "This method does not require that all the specified items exist, it determines whether there are no other items in the container". Thanks for the help guys!
  2. Hi all, So I'm experiencing an issue where my ConditionalSleep isn't blocking the execution of onLoop. For example this snippet below should sleep until my inventory only contains one kind of item. log("OnLoop has been run again"); new ConditionalSleep(Integer.MAX_VALUE) { public boolean condition() throws InterruptedException { return inventory.onlyContains('something'); } }.sleep(); But the logger shows that onLoop is being repetitively called. Am I misunderstanding how ConditionalSleep works here? If so what is the correct way of blocking my script from running.
  3. Thanks! That fixed it for me . Not sure why but the tutorials I was looking at said to copy the .class file over. How's my code though? Anything I could do better?
  4. Hi everyone, I'm just getting started writing scripts for RS and wrote my first script to auto fish and deposit in bank. Would love to get some feedback on anything I could be doing better. import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.util.Comparator; import java.util.Optional; import java.util.Random; @ScriptManifest(name = "FirstScript", author = "ultraswagger", version = 1.0, info = "", logo = "") public class FirstScript extends Script { private static Random gaussianGenerator = new Random(); private Comparator closestCageFishingSpot = (Comparator<NPC>) (a, b) -> getMap().distance(a.getPosition()) - getMap().distance(b.getPosition()); private ConditionalSleep bankConditionalSleep = new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return getBank().isOpen(); } }; private ConditionalSleep fishingConditionalSleep = new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return getInventory().isFull(); } }; private void depositFishToBank() { if(!Banks.CATHERBY.contains(myPosition())) getWalking().webWalk(Banks.CATHERBY); else { if(!getBank().isOpen()) bankConditionalSleep.sleep(); else getBank().depositAllExcept("Lobster pot"); } } @Override public void onStart() { log("Starting Script"); } @Override public int onLoop() { if (!this.myPlayer().isAnimating()) { if (this.getInventory().isFull()) { depositFishToBank(); } else { Optional<NPC> cageFishingSpot = this.getNpcs().getAll().stream() .filter(o -> o.hasAction("Cage")).min(closestCageFishingSpot); if (cageFishingSpot.isPresent()) { cageFishingSpot.get().interact("Cage"); fishingConditionalSleep.sleep(); } } } return (int)((double)1000 * gaussianGenerator.nextGaussian()); } @Override public void onExit() { log("Script has been stopped"); } } Thanks in advance!
×
×
  • Create New...