Jump to content

Recommended Posts

Posted

Hi guys,

 

Is there a way to get some sort of unique entity ID (or index in scene)? In the C++ headers I see some possible variables, but none seems to be documented in the Wiki. And I would like to have something in Lua.

 

Thanks in advance.

Posted

What I am doing is using the memory address as recommended by Josh. entity->GetAddress().

 

This isn't a bad idea, however what if the entity was removed; would a new entity not be able to take it's old memory address?

Perhaps it'd be best for Josh to add something like App:OnEntityCreated() so people can manually track Entities, of course this would have to be called for each entity created in the map as well when they are created.

Posted

GetAddress would not work in my case because I want the same ID on 2 different apps with the same scene (map). So I want to know what entity ID a map entity is. And it should be the same on the other app.

Posted

Give the name of the entities in the map unique names and use that. If they are run-time entities then you would need to save them off yourself anyway since you can't save them in the LE map.

Posted

Give the name of the entities in the map unique names and use that. If they are run-time entities then you would need to save them off yourself anyway since you can't save them in the LE map.

I'll consider 'syncing' by name yes. Although I would still have preferred some sort of ID system.

 

Thanks

Posted

I'll consider 'syncing' by name yes. Although I would still have preferred some sort of ID system.

 

Thanks

 

You could always manually track entities and assign them IDs, make your own function for creating entities that inserts them into a global entity table, and make a callback function when the map is loaded that inserts those entities into the global entity table.

 

Someone linked me a page that had:

if Map:Load(mapname,"Callback") == false then return false end

"Callback" being the name of a function, you could create a function like:

_G.entities = _G.entities or {}
local function Callback(ent)
ent.id = #_G.entities+1
table.insert(_G.entities, ent)
end

 

Note: I'm only refering to the entities table with _G in-case you already have a local 'entities' table in that file.

 

I personally would prefer LE force unique names in a map. I hate that you can have the same names in a given map. Just seems to go against reason to me smile.png

 

Agreed.

  • Upvote 1
Posted

I didn't know I could load a map with a callback. This will work perfect. Thanks CrazyCarpet.

 

And I agree with the unique naming. I would also like to have everything in lower case (filenames and entity names).

Posted

I didn't know I could load a map with a callback. This will work perfect. Thanks CrazyCarpet.

 

And I agree with the unique naming. I would also like to have everything in lower case (filenames and entity names).

 

Not a problem, as for the lowercase filenames, Josh made reference to it being a problem on Unix-based systems as they have a case-sensitive filesystem, it'd be possible for it to cause problems..

  • 6 years later...
Posted
On 03.10.2014 at 17:37, Rick said:

Haritadaki varlıkların adlarına benzersiz adlar verin ve bunu kullanın. Bunlar çalışma zamanı varlıkları ise, onları LE haritasında kaydedemeyeceğiniz için yine de kendiniz kurtarmanız gerekir.

Is there a sample code that I can refer to for lua what you said.

Posted

In the new engine, each entity in a scene has a unique UUID. These can even be used to identify entities in multiplayer games over the network.

  • Like 2

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted
On 3/4/2021 at 5:06 PM, simsek-emrah said:

Is there a sample code that I can refer to for lua what you said.

I promise you I did not say the above quoted lol :)

  • Haha 1
  • Confused 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...