Ywa Posted October 2, 2014 Share Posted October 2, 2014 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. Quote Link to comment Share on other sites More sharing options...
tjheldna Posted October 2, 2014 Share Posted October 2, 2014 What I am doing is using the memory address as recommended by Josh. entity->GetAddress(). Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted October 2, 2014 Share Posted October 2, 2014 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. Quote Link to comment Share on other sites More sharing options...
Ywa Posted October 3, 2014 Author Share Posted October 3, 2014 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. Quote Link to comment Share on other sites More sharing options...
Rick Posted October 3, 2014 Share Posted October 3, 2014 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. Quote Link to comment Share on other sites More sharing options...
Ywa Posted October 3, 2014 Author Share Posted October 3, 2014 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 Quote Link to comment Share on other sites More sharing options...
Rick Posted October 3, 2014 Share Posted October 3, 2014 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 2 Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted October 3, 2014 Share Posted October 3, 2014 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 Agreed. 1 Quote Link to comment Share on other sites More sharing options...
Ywa Posted October 4, 2014 Author Share Posted October 4, 2014 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). Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted October 5, 2014 Share Posted October 5, 2014 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.. Quote Link to comment Share on other sites More sharing options...
simsek-emrah Posted March 4, 2021 Share Posted March 4, 2021 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. Quote Link to comment Share on other sites More sharing options...
simsek-emrah Posted March 4, 2021 Share Posted March 4, 2021 Şimdiden teşekkür ederim. Quote Link to comment Share on other sites More sharing options...
Josh Posted March 5, 2021 Share Posted March 5, 2021 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. 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted March 8, 2021 Share Posted March 8, 2021 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 1 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.