Would Someone Explain EntityIDs For a Beginner?


#1

My Javascript knowledge is base. I understand enough to explore and attempt tweaking completed scripts. Now, I have run into a problem that I don’t really understand, but I suspect it has to do with EntityIDs.

This is the situtation: I have created 4 FBX models in 4 colors, so 16 variations. I imported one into my sandbox server and added some other entities and exported them as a one JSON. I was hoping I could copy the JSON and change the URL to the FBX for the 15 others. Didn’t work. I suspect it has something to do with the seemingly random serialized EntityIDs?

So, in this context, I want to understand the EntityID; how is it generated? Is it random or does it contain other information? Can I make/write my own EntityIDs? Or is there another reason my copied JSONs will rezz all the entities except the other 15 FBX models?


#2

EntityIDs are generated upon an items creation and are the reference ID to those items in the system. If you are familiar with Second Life, these are basically UUIDs.

All actions, including parenting, resizing, and getting properties all revolve around EntityIDs, but unlike Second Life, you cannot simply request for it normally. Instead, you have to do a bit of catching.

For example:

(function(){
    var entityID = null;
    this.preload = function(_entityID) {
        // Har, let's catch us an entityID (namely our own for this object)
        entityID = _entityID;
        // Let's prove what we caught
        print( entityID );
    }
});

Whereas in Second Life:

default {
    state_entry() {
        // We can request this at ANY time
        llSay( 0, (string)llGetKey() );
    }
}

As for generating entityIDs, this is not available, as each ID has to be unique, so the server will handle that. The reason it was copied into your JSON is that the JSON does a raw export, including the EntityIDs. This is important, however, since if you did any parenting, the importer has to negotiate the changes so the parenting still remains the same.

That being said, you CAN still generate UUIDs if needed (like making an app that doesn’t crosstalk):

var newUUID = UUID.generate();

As for the rezzing issue… that sounds like an odd behavior that is outside the scope of what I was aiming to talk about.