How to use getLoadedAt()

Discussion in 'Developer Support' started by DesignDecay, Jun 20, 2015.

  1. DesignDecay

    Joined:
    May 6, 2015
    Messages:
    16
    Likes Received:
    0
    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.
     
  2. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,431
    Likes Received:
    1,008
  3. Aidden

    Aidden The better executive ;)

    Joined:
    Dec 3, 2013
    Messages:
    3,050
    Likes Received:
    603
    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)
     
  4. DesignDecay

    Joined:
    May 6, 2015
    Messages:
    16
    Likes Received:
    0
    Near each other.
    --- Double Post Merged, Jun 20, 2015, Original Post Date: Jun 20, 2015 ---
    Erm... How do I PM you?
     
  5. Aidden

    Aidden The better executive ;)

    Joined:
    Dec 3, 2013
    Messages:
    3,050
    Likes Received:
    603
    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 (Text):
    1.  
    2. private GameObject go = GameObjects.getLoadedAt(new Coordinate(1,2,3), "Door").nearest();
    3.  
    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.
     

Share This Page

Loading...