M0lD Posted January 23, 2018 Share Posted January 23, 2018 So i have an Pivot in the map, And in an C++ Class i need to know where that entity is, and its position... Quote Link to comment Share on other sites More sharing options...
Rick Posted January 23, 2018 Share Posted January 23, 2018 I believe you have to loop over the world->entities and call ent = world:GetChild(index) and look for the name (ent:GetEntityValue("name") ?) and then you have the entity in which you can call GetPosition() on. Honestly, it would be nice if there was a handy dandy function(s) for this kind of stuff. The function would return a list (since names can be the same). Maybe even be able to tag entities with some kind of value in the editor and find all entities with that tag. 1 Quote Link to comment Share on other sites More sharing options...
M0lD Posted January 24, 2018 Author Share Posted January 24, 2018 Yeah... thanks Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 24, 2018 Share Posted January 24, 2018 9 hours ago, Rick said: Honestly, it would be nice if there was a handy dandy function(s) for this kind of stuff. The function would return a list (since names can be the same). This is something I have always found kinda odd when working with C++. I would have this massive switch/case list to get certain entities from my scene. Somehow that feels clunky. But even if there were an official function for this, it would probably do something similar in the background. Quote Link to comment Share on other sites More sharing options...
M0lD Posted January 24, 2018 Author Share Posted January 24, 2018 I know its overused but "I hope this is "Fixed" in leadwerks 5" Quote Link to comment Share on other sites More sharing options...
Rick Posted January 24, 2018 Share Posted January 24, 2018 6 hours ago, AggrorJorn said: This is something I have always found kinda odd when working with C++. I would have this massive switch/case list to get certain entities from my scene. Somehow that feels clunky. But even if there were an official function for this, it would probably do something similar in the background. One way to do this ourselves (but still would be nice if this was part of the engine), is to loop over all the world->entities and get their names and store them in a map<string, vector<Entity*>>. Now we have a dictionary where the key is the name and each entity is in the list for the key that matches it's name (since entities can have the same name). Then we can just access the entities by name like: entiites["MyPivot"][0] if you know there is only 1 with that name. What was the case statement for? It's been awhile so I don't recall. Was it for each different type and you cast or something? Quote Link to comment Share on other sites More sharing options...
M0lD Posted January 24, 2018 Author Share Posted January 24, 2018 I dont need to loop it overcand over if i only need it ween the map starts, im just makeing the camera, in C++ And set its location to an pivot... Quote Link to comment Share on other sites More sharing options...
Rick Posted January 24, 2018 Share Posted January 24, 2018 Yeah, I'm saying you would loop over world->entities once and add them to the map of lists with the name as the key and then you can get it via name which isn't a straight loop again, but the idea is today you just need the pivot but tomorrow you need another pivot, then the lights, then etc etc. 1 Quote Link to comment Share on other sites More sharing options...
M0lD Posted January 24, 2018 Author Share Posted January 24, 2018 22 hours ago, Rick said: I believe you have to loop over the world->entities and call ent = world:GetChild(index) and look for the name (ent:GetEntityValue("name") ?) and then you have the entity in which you can call GetPosition() on. Honestly, it would be nice if there was a handy dandy function(s) for this kind of stuff. The function would return a list (since names can be the same). Maybe even be able to tag entities with some kind of value in the editor and find all entities with that tag. I dont find world.GetChild()... Quote Link to comment Share on other sites More sharing options...
Rick Posted January 24, 2018 Share Posted January 24, 2018 foreach(auto e in world->entities) { if(e->GetKeyValue("name") == "player") { } } It's been awhile since I've worked on the C++ side of things, or in LE really. Above I believe is the way to loop over entities in the world after the map is loaded. Sorry, no GetChild() needed I guess. Might be more like the below. Sorry, like I said been awhile for(auto e : world->entities) { } 1 Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 25, 2018 Share Posted January 25, 2018 This information used to be in the documentation btw. I would expect a find the variable 'entities' here somewhere: https://www.leadwerks.com/learn?page=API-Reference_Object_World Quote Link to comment Share on other sites More sharing options...
M0lD Posted January 25, 2018 Author Share Posted January 25, 2018 The documentation is pretty much gone now becuse of Leadweks 5? Becuse the "Old documentation" links are talking if stuff thats gone now." (I found out leadwerks had an forum long after i started useing it) Haveing everything documented and enableing users to add examples like comments would make a lot of the currently active questions non-existant... Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 25, 2018 Share Posted January 25, 2018 18 minutes ago, M0lD said: The documentation is pretty much gone now becuse of Leadweks 5? Becuse the "Old documentation" links are talking if stuff thats gone now." (I found out leadwerks had an forum long after i started useing it) Haveing everything documented and enableing users to add examples like comments would make a lot of the currently active questions non-existant... No. All the documentation found here: https://www.leadwerks.com/learn?page= is part of Leadwerks 4.x . It is just a new documentation system which was filled from scratch. So some information in the old documentation website might not be written in the new documentation system. Adding comments to pages would be nice, but for now we would have to file a bug report. Things get fixed very quickly if described properly. Example. Quote Link to comment Share on other sites More sharing options...
M0lD Posted January 25, 2018 Author Share Posted January 25, 2018 2 minutes ago, AggrorJorn said: No. All the documentation found here: https://www.leadwerks.com/learn?page= is part of Leadwerks 4.x . It is just a new documentation system which was filled from scratch. Adding comments to pages would be nice, but for now we would have to file a bug report. Things get fixed very quickly if described properly. Example. But the current 4.x documentation is missing much Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 25, 2018 Share Posted January 25, 2018 As I said, Leadwerks rewrote all documentation for the new system. It is perfectly possible small details are forgotten. In the old documentation you see how the Entities member is listed: http://web.archive.org/web/20150502074238/http://www.leadwerks.com:80/werkspace/page/documentation/_/command-reference/world 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.