Welcome!

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

Sign up now!

How to use getLoadedAt()

Joined
May 6, 2015
Messages
16
Can someone give me some guidance on how to properly use getLoadedAt(). More specifically I am trying to perform an action on a specific GameObject when there are multiple in the vicinity.
 
Author of MaxiBots
Joined
Dec 3, 2013
Messages
7,032
When you say multiple in the viscinity, do you mean near each other or on the same tile? And i'd recommend using queries instead of the getLoaded methods (in all areas)
 
Author of MaxiBots
Joined
Dec 3, 2013
Messages
7,032
Okay so basically getLoadedAt() can be used to get the object(s) loaded at a specified coordinate and can be filtered by name or id.
It returns a locatable query result which is a special list of the objects found at that coordinate. On this list you can call .first() .last() .nearest() etc. to select a gameobject from the list.
For example
Code:
private GameObject go = GameObjects.getLoadedAt(new Coordinate(1,2,3), "Door").nearest();
Of course, don't forget to null check. But yeah, as i said before, i recommend using .newQuery() and chaining queries to that. It allows you to filter via multiple different things and the code looks nice and clean.
 
Top