Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Open and close gate?

Joined
Mar 20, 2015
Messages
3
Hey guys! This is my first forum post so if it's in the wrong section please move it or let me know.

I'm working on my first bot, and one thing I'm stuck on is gates. How do I check if its open or closed? Or is there a standard way of dealing with walking past open/closed gates?
 
Joined
Nov 3, 2013
Messages
609
You have a couple of options:
1) You'll need to grab the tile location. It should be different when the door/gate is opened/closed.
2) If the location doesn't change, then try the actual model ID, that should be different.
3) If those can't tell the difference, then try looking at the value of getOrientation() on the gameobject.

Hope this helps.
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,044
To answer your question there is in fact a standard way to deal with doors and other such navigation related items, but it involves adding to the web walking implementation. That is an advanced topic for a beginner, but I know a lot of our great devs would be happy to explain it to you in our Skype dev chat. PM me your Skype if you're interested.
 
Joined
Nov 5, 2014
Messages
505
Another way would be to run a query to find nearby closed gates. (Adjust the query to search within a certain area/distance of you)

Code:
LocatableEntityQueryResults<GameObject> closedGates = GameObjects.newQuery().names("Gate").actions("Open");

You can then do something like:

Code:
if (!closedGates.isEmpty()) {
GameObject gate = closeGates.nearest();
// Code to open a gate
}
 

lad

Joined
Feb 6, 2015
Messages
241
You can try using coordinates at each side of the door, and check if it's reachable or not. If it's not reachable. door.interact("Open");
I personally haven't done it but if I did that's how I'd do it.
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
You can try using coordinates at each side of the door, and check if it's reachable or not. If it's not reachable. door.interact("Open");
I personally haven't done it but if I did that's how I'd do it.
Just remember that reachability is an intense calculation is done frequently.
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
Yes but it is hard not to use it at times. Especially when you have absolutely no choice.
I've yet to encounter a single situation like that, I've always managed to find a solution even when it seemed really impractical.
 
Top