Jump to content

explanation onStart()


Joseph

Recommended Posts

can someone explain to me this \/

catch try {...................} 
catch (interruptedException e)
// TODO Auto-generated catch block
e.printStackTrace(); 
}

im trying to create a farming script, and on the onStart() i want it to do more then one action. But i don't fully understand the (catch............). do i only need one (Catch..........), or more then one, if my onStart() has more then one action.

public void onStart(){
if (client.getInventory().contains(ectophial)
&& !EctoArea.contains(myPlayer())){
try {
this.client.getInventory().interactWithId(ectophial, "Empty");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (myPlayer().getAnimation()== 714) {
while(myPlayer().getAnimation()== 714) {
try {
sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
state = State.WALKTOECTOHERB;
}
}
}

 

 

Edited by josedpay
Link to comment
Share on other sites

so it should look something like this then 

	public void onStart() throws InterruptedException {
		if (client.getInventory().contains(ectophial)
			&&!client.getMyPlayer().isInArea(EctoArea))	{
			client.getInventory().interactWithId(ectophial, "Empty");
				if (myPlayer().getAnimation()== 714)	{
					while (myPlayer().getAnimation()== 714)	{
							sleep(1000);
					}
				}
			state = State.WALKTOECTOHERB;
			}
		}

 i try this out then Eclipse is having a sissy fit, it say you remove the exception.

 

Edited by josedpay
Link to comment
Share on other sites

What the error? when you hover over the red line what does it say?

 

EDIT: nvm remove the throw thing, the onStart method in the Scrip class doesnt throw InterruptedException, I think you have to add the try and catch blocks again

 

And what is try and catch basically is a code that try to preform the code between the try {} and if something unexcepted happened it catches the errors.

Edited by Mithrandir
Link to comment
Share on other sites

What the error? when you hover over the red line what does it say?

 

EDIT: nvm remove the throw thing, the onStart method in the Scrip class doesnt throw InterruptedException, I think you have to add the try and catch blocks again

 

And what is try and catch basically is a code that try to preform the code between the try {} and if something unexcepted happened it catches the errors.

	public void onStart() {
		if (client.getInventory().contains(ectophial)
			&&!myPlayer().isInArea(EctoArea))	{
			try {
				client.getInventory().interactWithId(ectophial, "Empty");
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
				if (myPlayer().getAnimation()== 714)	{
					while (myPlayer().getAnimation()== 714)	{
							try {
								sleep(1000);
							} catch (InterruptedException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
					}
				}
			state = State.WALKTOECTOHERB;
			}
		}

so then this (what i had in the beginning, with just a little tweaks wink.png )

Link to comment
Share on other sites

	public void onStart() {
		if (client.getInventory().contains(ectophial)
			&&!myPlayer().isInArea(EctoArea))	{
			try {
				client.getInventory().interactWithId(ectophial, "Empty");
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
				if (myPlayer().getAnimation()== 714)	{
					while (myPlayer().getAnimation()== 714)	{
							try {
								sleep(1000);
							} catch (InterruptedException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
					}
				}
			state = State.WALKTOECTOHERB;
			}
		}

so then this (what i had in the beginning, with just a little tweaks wink.png )

 

public void onStart() {
		if (client.getInventory().contains(ectophial)
			&&!myPlayer().isInArea(EctoArea))	{
				client.getInventory().interactWithId(ectophial, "Empty");
				if (myPlayer().getAnimation()== 714)	{
					while (myPlayer().getAnimation()== 714)	{
							try {
								sleep(1000);
							} catch (InterruptedException e) {
	 						e.printStackTrace();
							}
					}
				}
			state = State.WALKTOECTOHERB;
			}
		}
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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