Jump to content

Checking for a suitable firemaking space


Recommended Posts

Posted

Hi guys - apologies in advance this is my first script but I'm trying to set up a method that locates a safe 5x1 area to firemake.

I've declared my current position and the position 5 tiles west of my current position to create a 5x1 area

	public void tileCheck() {
		Position myPosition = myPlayer().getPosition();
		Position minusFivePosition = new Position((myPosition.getX()-5), myPosition.getY(), myPosition.getZ());
		Area safeToFiremake = new Area(minusFivePosition, myPosition);

From here, I'm a bit stuck. I want to create an if statement that says "If safeToFiremake does not contain any objects, firemake, else move somewhere else"

I've been browsing the api for a while and I couldn't find a way to check a defined area doesn't contain any objects - I would be grateful for any advice please 

Posted
1 hour ago, DirtyDick said:

Hi guys - apologies in advance this is my first script but I'm trying to set up a method that locates a safe 5x1 area to firemake.

I've declared my current position and the position 5 tiles west of my current position to create a 5x1 area

	public void tileCheck() {
		Position myPosition = myPlayer().getPosition();
		Position minusFivePosition = new Position((myPosition.getX()-5), myPosition.getY(), myPosition.getZ());
		Area safeToFiremake = new Area(minusFivePosition, myPosition);

From here, I'm a bit stuck. I want to create an if statement that says "If safeToFiremake does not contain any objects, firemake, else move somewhere else"

I've been browsing the api for a while and I couldn't find a way to check a defined area doesn't contain any objects - I would be grateful for any advice please 

Look at the method getEmptyPosition near the bottom, you could just take it and change it around a bit to check a full area

https://github.com/Explv/Tutorial-Island/blob/master/src/sections/SurvivalSection.java

  • Heart 1

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...