Jump to content

Door Handler


harrypotter

Recommended Posts

According to the API I can check if an entity is reachable: https://osbot.org/api/org/osbot/rs07/api/DoorHandler.html#canReachOrOpen-org.osbot.rs07.api.model.Entity-

However the following always returns true even if it should return false:

NPC juliet = script.npcs.closest("Juliet");
log(getDoorHandler().canReachOrOpen(juliet.getPosition()));

 

Edited by harrypotter
Link to comment
Share on other sites

22 minutes ago, harrypotter said:

According to the API I can check if an entity is reachable: https://osbot.org/api/org/osbot/rs07/api/DoorHandler.html#canReachOrOpen-org.osbot.rs07.api.model.Entity-

However the following always returns true even if it should return false:


NPC juliet = script.npcs.closest("Juliet");
log(getDoorHandler().canReachOrOpen(juliet));

 

Juliet isn't a door though?

I'd do something like this:

if (julietArea.contains(myPlayer()) {
	RS2Object door = getObjects.closest("Door");
	if (door != null && door.hasAction("Open")) {
		door.interact("Open");
	}
	
	// then rest of code to interact with the NPC "Juliet"

}

EDIT: julietArea being the area you are in when wanting to interact with Juliet. Use @Explv 's dope map to find the area for it by going up a floor (https://explv.github.io/).

Edited by Magarac
Link to comment
Share on other sites

19 minutes ago, Magarac said:

Juliet isn't a door though?

I'd do something like this:


if (julietArea.contains(myPlayer()) {
	RS2Object door = getObjects.closest("Door");
	if (door != null && door.hasAction("Open")) {
		door.interact("Open");
	}
	
	// then rest of code to interact with the NPC "Juliet"

}

EDIT: julietArea being the area you are in when wanting to interact with Juliet. Use @Explv 's dope map to find the area for it by going up a floor (https://explv.github.io/).

Sorry my snippet should read: 

NPC juliet = script.npcs.closest("Juliet");
log(getDoorHandler().canReachOrOpen(juliet.getPosition()));

This still returns true for the position, even if behind a door.

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

3 minutes ago, harrypotter said:

Sorry my snippet should read: 


NPC juliet = script.npcs.closest("Juliet");
log(getDoorHandler().canReachOrOpen(juliet.getPosition()));

This still returns true for the area, even if behind a door.

Hmm I'm not exactly sure why it's returning true, other than the fact that (reach || open) might be working like an OR statement does and since it CAN open the door it returns true always. Try doing the door check like I posted, cause doors always have either a "Open" or "Close" option.

  • Like 1
Link to comment
Share on other sites

2 minutes ago, Magarac said:

Hmm I'm not exactly sure why it's returning true, other than the fact that (reach || open) might be working like an OR statement does and since it CAN open the door it returns true always. Try doing the door check like I posted, cause doors always have either a "Open" or "Close" option.

You could be right, flew straight over my head the naming there haha!

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