What has 'Entities.identifyEntity' [undefined] is not a function been changed too


#1

im trying to get this script thoys made workin’
but getting an error

‘Entities.identifyEntity’ [undefined] is not a function

"var entities = Entities.findEntities(MyAvatar.position, 1000);

var oldURL = “where they are now:”;
var newURL = “where thems going too”;

for (var i = 0; i < entities.length; i++) {
var entityID = Entities.identifyEntity(entities[i]);
var props = Entities.getEntityProperties(entityID);
if (props[‘modelURL’].substr(0, oldURL.length) === oldURL) {
var postpart = props[‘modelURL’].substr(oldURL.length - props[‘modelURL’].length);
Entities.editEntity(entityID, {modelURL: newURL + postpart});
}
}

but its throwing an error suspects they changed something since i used it last
any ideas?


#2

Such a function would do nothing but return the input. The results of findEntities is a list of entity IDs

var entities = Entities.findEntities(MyAvatar.position, 1000);
for (var i = 0; i &lt; entities.length; i++) {    
    var entityID = entities[i];
    ...
}

#3

Yep, @Jherico is right. The findEntities function used to return different data, you had to identify the entity ID’s. This has become easier now, let me fix it up for you @Judas

const SEARCH_DISTANCE = 1000; // in meters
const OLD_MODEL_URL= "where they are now:";
const NEW_MODEL_URL = "where thems going too";
const MODEL_URL_PROPERTY = 'modelURL';

var entities = Entities.findEntities(MyAvatar.position, SEARCH_DISTANCE);

for (var i = 0; i < entities.length; i++) {
    var props = Entities.getEntityProperties(entities[i], [MODEL_URL_PROPERTY]);
    if (props[MODEL_URL_PROPERTY].substr(0, OLD_MODEL_URL.length) === OLD_MODEL_URL) {
        var newProperties = {};
        newProperties[MODEL_URL_PROPERTY] = NEW_MODEL_URL + props[MODEL_URL_PROPERTY].substr(OLD_MODEL_URL.length - props[MODEL_URL_PROPERTY].length);
        Entities.editEntity(entities[i], newProperties);
    }
}

#4

I did loook at his reply but u know when you learn say french and learn how to ask directions to the translation, then the person replies in french and you don’t understand a word of it but dont like to say.
well i had one of those moments