Scripts: GetEntity ID


While working on an entity rotation script, I noticed a disturbing lack of an ability to get a key of an entity to which a script has been attached to:

While a script that spawns an entity can track a status of another entity, the script doesnt really know anything about the entity it is attached to, until something interacts with the entity.

So is there a method that I may have missed that allows one to get the uuid of the entity the script has been added to?

Edit: disregard, its preload(uid) that is first called.


I think there is, but it’s late here. look in the example scripts in the entityscripts directory. Am pretty sure there’s example that request the entityid. something with this. still stuff i need to understand complete.


this however is just the owner of function it is being called in, and if it is called inside the main constructor. (the (function(){ }) object )

It is technically an empty object unless you otherwise defined to have an ID: printing this out also prints out an empty object when passed through Stringify:

In anycase, I think i found it after digging some more., its preload function definition that is first called


To delete blocks I have gotten the id on this way:

function blocksdelete()
{ var ids = Entities.findEntities(MyAvatar.position, 100);
for (var i = 0; i < ids.length; i++)
var id = ids[i];
var properties=Entities.getEntityProperties(id);
{ print(“name:” +properties.modelURL);
{ print(“box” +properties.type);



So if you know the name of the entity, you also get the Id.