Jump to content

Help me fix looting.


Recommended Posts

Posted
public void process(main script) {
			
			GroundItem salmon = script.getGroundItems().closest("Raw salmon");
			
			script.log(salmon.isVisible());
			
			if(salmon != null && salmon.isVisible()) {
				
				salmon.interact("Take");
				
			} else {
				
				GroundItem trout = script.getGroundItems().closest("Raw trout");
				
				script.log(trout.isVisible());
				
			    if(trout != null && trout.isVisible()) {
			    	
			    	trout.interact("Take");
			    }
				
			}


		}

	},

What am I doing wrong?

 

 

you're logging if it is visible before you null check it. you must null check before using it at all

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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