Jump to content

jca

Members
  • Posts

    390
  • Joined

  • Last visited

  • Days Won

    1
  • Feedback

    100%

Posts posted by jca

  1. 1 hour ago, Rumple said:

    So one question why do you check null and less than 0. Shouldn’t I be checking to see if there is more than 0?

    okay so If I need to check if it’s false do I just add .equals(False) or == false? Because if both are false I need to hop worlds.

    I'm checking for greater than. 

    Greater than: > checks if the reference on the left is greater than the reference on the right.

    Less than: < check if the reference on the left is less than the reference on the right.  

    5 > 2 // true
    2 < 5 // true 
    5 < 2 // false

    So if the shop has greater than 0 buy the soda ash.

    To check if it's false add an exclamation mark before the boolean function.

    if ( !sodaAshToBuy() ){
    	//hop
    }

     

  2. 5 hours ago, Rumple said:

     

    Don’t I have to specify which widget I’m using as I have a few that I am checking. These are just the ones that are getting flagged because I’m checking if there is stock in shop?!

    It’s throwing a NullPointerException because you’re calling getItemAmount() on a widget that doesn’t exist somewhere in the loop.

    private boolean sodaToBuy(){
    	RS2Widget sodaAsh = getWidgets().get(300, 16, 23);
    
    	return sodaAsh != null && sodaAsh.getItemAmount() > 0;
    }

    Also you don't need to use the equal to operator when checking booleans, instead

    if ( sodaToBuy() ){
    	buySoda();
    }

     

  3. getWalking().walk(Position p);

    Has a minimum distance threshold greater than zero, so if you’re within the threshold (I’m not 100% what it is) the event is considered successful.

    You need a custom walk event. 

    WalkingEvent myWalk = new WalkingEvent(Position p); 
    
    myWalk.setMinDistanceThreshold(0);
    
    execute(myWalk);

    Also you should restructure to avoid while() loops. 

    • Like 3
  4. 24 minutes ago, Rumple said:

    Thats the thing is that you do not stop animating after 5 minutes u keep pumping except it is without exp. I either have to set a timer for 5 mins or check to make sure im getting str exp before continuing to pump.

    I see. 

    private long strengthXp; 
    
    public int onLoop(){
    	
        if ( myPlayer().isAnimating() && hasGainedStrengthXp() ){
            strengthXp = getExperienceTracker().getGainedXp(Skill.STRENGH);
            return 3000; 
        } else { 
        	// do loop 
        } 
        return 200; 
    }
    
    private boolean hasGainedStrenghtXp(){
    	return getExperienceTracker().getGainedXp(Skill.STRENGTH) > strengthXp; 
    }

    This will check whether your player is animating and current strength experience is greater than previous strength experience, if it is then set new strength xp gauge and pause for 3 secs until the next check. 

    You can improve this with a conditional sleep and interval to check. 

    • Like 1
  5. 19 hours ago, Rumple said:

    Okay So i thought i did this right.

    I want it to pump until it doesnt get str exp. which is 5 mins.

    once the xp stops it should move on the the next object which is the shoveling the coke until it sees a message (should do whole inv)

    move on to filling the furnace it should give another message when you are out of coke.

    then move on back to pumping and loop around like that, but it doesnt.

    just starts to pump and gets few exp then skips to furnace and stops when gets message. 

     

    help pls.

    What you're doing seems a little strange... 

    public int onLoop(){
    
      if ( ! myPlayer().isAnimating() ){
    
          if ( needsToRefuelStove() ){ 
              refuelStove(); 
          } else if ( needsToShovelCoke() ){
              shovelCoke(); 
          } else {
              operatePump(); 
          }
    
      }
    
      return 200; 
    
    }
    
    private void refuelStove(){}
    
    private void shovelCoke(){}
    
    private void operatePump(){
    
    	RS2Object pump = getObjects().closest("Pump"); 
    
    	if ( pump != null && pump.interact("Operate") ){
    
    		new ConditionalSleep(3000){
    			@Override
    			public boolean condition() throws InterruptedException {
    				return myPlayer().isAnimating(); 
    			}
    		}.sleep()
    
    	}
    
    }
    
    /*
    	Booleans for you to fill
    */
    
    private boolean needsToRefuelStove(){
    	return false; 
    }
    
    private boolean needsToShovelCoke(){
    	return false; 
    }

    By splitting your code out like this it's a lot easier to see what's going on. As far as checking strength XP, a better way would be to check if your player is animating, if so you don't need to do anything, if not then see which action is next. 

    • Like 2
  6. 23 hours ago, Dickie said:

    Morning,

    Just thought I would drop by and say hello!

    I have played Runescape on and off since 02. Got big into botting/scripting back in RSC days with STS. Work kept me coming back a forth over the years but never really had the time to play, But new job working away from home gives me all evening and night free so looking to start a skilling services along with selling ready built accounts. Take me some time to build up some rep before account sales go on sale. So any advice on starting would be appreciated!

    Dickie

    Welcome to the community! Just be genuine and helpful, you'll soon build up a rep. 

  7. 3 hours ago, elbojoloco said:

    Hey, how do I get the closest to me from the getObjects().getAll() part?

    getObjects().closest("Ore vein") 	

    That will return the closest object with that name from all the objects in getObjects().getAll(), which returns all the objects in the loaded region. If you want to use getAll() use Java's stream API.

    getObjects().getAll().stream().filter(obj -> obj.getName().equalsIgnoreCase("Ore vein")).findFirst().orElse(null); 

    That will return the first object in the collection with the name "Ore vein". If you want to compare distance that you have to use .min() 

  8. 21 hours ago, elbojoloco said:

    I fixed it by checking wether the object located at the clicked vein's coordinates name equals "Depleted vein". Another issue i am walking into: the getObjects().closest() is not looking further than 3-4 tiles it seems, I want it to look on the whole screen, how can i do that?

    Coordinates are not the best way to do it. Look at the debug.   

    getObjects().getAll() returns all objects in the loaded region, if closest() is within 3-4 tiles it’ll return that. 

  9. 11 minutes ago, elbojoloco said:

    Nope, it just instantly quits the conditionalsleep and starts new loop.... I've discovered on the forums that apperantly an Ore vein has multiple states but I dont know how to take that vein and listen to any state changes for example, if there was a callback for a state change thatd be amazing.. or something along those lines..

    Use the entity hover debug to look at what you need to listen for 

×
×
  • Create New...