Look()'s returned objects should not have a different name based on their type



  • It is currently extremely difficult to use the look() statement to get the ids of any objects in the location. Because the sub-object in the return containing data about the target object is named after the type of the object (instead of being called, for instance, objectData), the only way to get the IDs of all objects in a location is an extremely exhaustive check of every single possible object type for every single object in the tile. This is a massive drain on resources that could be avoided if that variable name did not change when the object's type changed.



  • The name of the object is stored in the type property.

    The following line is one possible way to get an array of the id's of objects at position pos:

    pos.look().reduce( (arr,lookObj) => lookObj[lookObj.type].id ? arr.concat([lookObj[lookObj.type].id]) : arr, [] )
     


  • @Crusher48 you may already know this, but you should not ever use look()

    Basically look() calls lookFor() 8 different times, one for every possibly LOOK_* constant, and merges the results for you.  This is an insane waste of CPU since you likely only need a small subset of the results.

    TL;DR don't use look().  Use lookFor() instead.