Jump to content

Checking for a suitable firemaking space


DirtyDick

Recommended Posts

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 

Link to comment
Share on other sites

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
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.
Note: Your post will require moderator approval before it will be visible.

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