Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Vogelbekdier

    Members
    • Posts

      10
    • Joined

    • Last visited

    Posts posted by Vogelbekdier

    1. 1 minute ago, camalCase said:

      what happens in walkToWheat

      Quote
      Area wheatArea = new Area(3162, 3294, 3159, 3296);
      walkToArea(wheatArea);
      
      private void walkToArea(Area area) {
          if (!area.contains(Players.getLocal())) {
              Walking.walk(area.getRandomTile());
              Sleep.sleepUntil(() -> Walking.getDestinationDistance() < 5, longSleep);
          }
      }
    2. Quote
      12 minutes ago, camalCase said:

      what happens inside those methods? and where is this code block positioned? sounds like wheat is never gets assigned again after its initialized but i cant tell not enough code

      
      // i think using guard clauses help your code look nicer and be clearer :3 like this
      if (wheat == null) {
      	walkToWheat();
        	return 2400; // or whatever
      } 
      pickWheat();
      return 2400; // or whatever

       

      Quote
      private void pickWheat() {
          GameObject wheat = GameObjects.closest((gameObject) -> {
              return gameObject != null && gameObject.getName().equals("Wheat") && gameObject.canReach() && gameObject.hasAction(new String[]{"Pick"});
          });
      
          if (!Inventory.contains("Grain")) {
              wheat.interactForceLeft("Pick");
              Sleep.sleepUntil(() -> Inventory.contains("Grain"), longSleep);
          } else if (Inventory.contains("Grain")) {
              gotGrain = true;
          }
      }

      This doesn't work because when I start the script when Grain == null it always stays null. So it just walks over to the area and gives error "Grain == null" and freezes only when I restart the script grain becomes != null and it will pick one wheat. If I drop it manually again it will just stand there trying to pick another one but never actually does.

       

       

    3. I'm trying to null check a GameObject and interact if it's != null or else walk over.

      Initial null check comes back false and I walk over to the area, but even when I'm standing in a field of wheat it keeps still returning wheat == null. Only when I restart the script it will turn to true.

      Help please.

      Quote

      GameObject wheat = GameObjects.closest("Wheat");

      if (wheat == null) {

      walkToWheat();

      } else if (wheat != null) {

      pickWheat();\

      }

       

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.