Jump to content

peckerwood

Members
  • Posts

    4
  • 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.

peckerwood's Achievements

Newbie

Newbie (1/10)

0

Reputation

  1. This is a matter of control flow statements. In java you use these statements to control how expressions are evaluated. Typically without the use of control flow statements your program will be read from top to bottom. In this case you want to evaluate if your inventory is full, whether or not the area (Varrock bank) contains your player, and if the bank is open. You can use if statements to evaluate these but your implementation is convoluted. Try breaking it up in the 3 sections I described above. Test for these conditions. if they are met, what do you want your script to do and vis versa if they are not met what should happen. for example: if(getInventory.isFull) is not a necessary condition for the rest of your code. separate it: if (inventory.isFull() && !area.contains(myPlayer())) { getWalking().webWalk(area); } or try a while loop that will evaluate all code inside its brackets so long as the condition is met. example: while(!area.contains(myPlayer())) { if (inventory.isFull()) { getWalking().webWalk(area); break; } } this means that while your player is not in the defined area it will evaluate if the inventory is full. if it is full you will walk to the area. This code will constantly loop so long as your player is not in the area. Ultimately if you want to actually understand you need to teach yourself. Read the oracle guide on control flow statements: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/flow.html
  2. just in case anyone is experiencing the same issue, in order to utilize other classes you need to first pass the method provider as a field then create a constructor from that field in the new class. Example: public class PickUp { //the class field public final MethodProvider methods; //the constructor public PickUp(MethodProvider methods) { this.methods = methods; } //implementation of the MethodProvider field in order to access the OSBot Api class public void itemCheck(){ if(methods.inventory.isFull()){ } } }
  3. Thank you! managed to get it working passing a method provider to the classes. Testing for bugs now but seems everything works as it should!
  4. I seem to have to errors in my code however when I add my .jar file to the scripts folder I am unable to run it from the client. I know its an issue with my code but can't seem to figure out what the problem is. I am new to this whole thing but would appreciate any help I can get! import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(version = 1.0, logo = "", info = "Combat", author = "P", name = "bot") public class Main extends Script{ public long maxSleep = 1234; @Override public void onStart() throws InterruptedException { super.onStart(); log("Script Started"); } @Override public int onLoop() throws InterruptedException { combat combat = new combat(); combat.findMonster(); Eat eat = new Eat(); eat.eat(); eat.dropInv(); return 432; } @Override public void onExit() throws InterruptedException { super.onExit(); log("Script Ended"); } } import org.osbot.rs07.api.model.Entity; public class combat extends Main { public void findMonster() throws InterruptedException { Entity monster = getNpcs().closest("Cow", "Chicken"); if(monster != null){ monster.interact("Attack"); if((monster == null) && !myPlayer().isAttackable()){ sleep(343); } } else { sleep(maxSleep); } } } import org.osbot.rs07.api.GroundItems; import org.osbot.rs07.api.Inventory; import org.osbot.rs07.api.model.Character; public class Eat { private Inventory inventory; private Character myChar; private GroundItems pickUp; public void eat() { int health = myChar.getHealthPercent(); if(health < 20){ inventory.getItem("Beef").interact("Eat"); if(!inventory.contains("Beef") && !inventory.isFull()){ pickUp.closest("Raw Beef").interact("Pick Up"); } } } public void dropInv(){ if(inventory.isFull()){ inventory.dropAll("Bones", "Cow Hide"); } } }
×
×
  • Create New...