Jump to content
Rumple

Need some help.

Recommended Posts

 

Hi I am struggling a little bit with compiling.

I want this to pump indefinntly until I stop getting str xp witch should be every 5 mins, then it should continue to the next object which is the coke and fill up until it recieves a message to continue (which mean all spades full x 28) then should move on to fill the stove with coke and wait for another message to continue, once it sees the message it should go back to pumping until the xp stop and loop again.

 

public int onLoop() throws InterruptedException {
        int starting = getExperienceTracker().getGainedXP(Skill.STRENGTH);
        Entity nextObj = getObjects().closest(obj -> Arrays.asList(names).contains(obj.getName()) &&
                Arrays.asList(actions).contains(obj.getActions()[0]) && (getMap().canReach(obj)) && !obj.equals(previous));
        if (nextObj != null && myPlayer().getInteracting() == null && !getDialogues().isPendingContinuation()) {
            if (nextObj.interact(nextObj.getActions()[0])) {
                new ConditionalSleep(10000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getExperienceTracker().getGainedXP(Skill.STRENGTH) < starting;
                    }
                }.sleep();
            } if (getExperienceTracker().getGainedXP(Skill.STRENGTH) > starting){
                previous = nextObj;
            }
        }
        return 250;
    }

Please help.

 

http://prntscr.com/lnqzk2

Link to comment
Share on other sites

Had a quick google and found a stack overflow question which has seems to have a good answer on how to solve your problem: https://stackoverflow.com/questions/23211589/error1-1illegalcharacter-ufeff-when-compiling-on-android-studio

Top answer:

Quote

That's a problem related to BOM (Byte Order Mark) character. Byte Order Mark BOM is a Unicode character used for defining a text file byte order and comes in the start of the file. Eclipse doesn't allow this character at the start of your file, so you must delete it. For this purpose, use a rich text editor, such as Notepad++, and save the file with encoding "UTF-8 without BOM." That should remove the problem.

Incorrectly copy/pasting code from somewhere in the forums sometimes gives me syntax errors, so be careful when you're using snippets etc.

Edited by R I F T
Added possible cause
Link to comment
Share on other sites

Okay So i thought i did this right.

 @Override
    public int onLoop() throws InterruptedException {
        int starting = getExperienceTracker().getGainedXP(Skill.STRENGTH);
        Entity nextObj = getObjects().closest(obj -> Arrays.asList(names).contains(obj.getName())
                && Arrays.asList(actions).contains(obj.getActions()[0]) && (getMap().canReach(obj)) && !obj.equals(previous));
        if(nextObj != null && myPlayer().getInteracting() == null && getExperienceTracker().getGainedXP(Skill.STRENGTH) > starting){
            if(nextObj.interact(nextObj.getActions()[0])){
                new ConditionalSleep(1000){
                    @Override
                    public boolean condition() throws InterruptedException{
                        return getExperienceTracker().getGainedXP(Skill.STRENGTH) < starting;
                    }
                }.sleep();
            }if (getExperienceTracker().getGainedXP(Skill.STRENGTH) > starting && getDialogues().isPendingContinuation()) {
                previous = nextObj;
            }
        }
        return 250;
    }

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.

Link to comment
Share on other sites

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. 

Edited by jca
  • Like 2
Link to comment
Share on other sites

6 hours ago, jca said:

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. 

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.

Link to comment
Share on other sites

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. 

Edited by jca
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...