jamesmintram Posted June 10, 2013 Posted June 10, 2013 Hi, I am trying to work out the best way for me to find an entity in the world after using Map::Load. I have an entity I have positioned in the Leadwerks editor with the name "SkyBox", after calling Map::Load what is the best way to retrieve this entity (in C++) Regards, James Quote
YouGroove Posted June 10, 2013 Posted June 10, 2013 You have some example here : http://www.leadwerks.com/werkspace/page/tutorials/_/map-loading-and-getting-entities-r44 Quote Stop toying and make games
beo6 Posted June 10, 2013 Posted June 10, 2013 Or try the code klepto posted here: http://www.leadwerks.com/werkspace/topic/6959-map-loading/#entry57032 haven't tried that myself but when there is already a list in world->entities it should work. Quote
Rick Posted June 10, 2013 Posted June 10, 2013 Note that I'm not sure if world.entities works in Lua. I seem to recall hearing that it didn't. Quote
beo6 Posted June 10, 2013 Posted June 10, 2013 since he wrote (in C++) it shouldn't be a problem. But good hint anyway. Quote
jamesmintram Posted June 10, 2013 Author Posted June 10, 2013 Thanks for the replys guys! I went with: Entity *EntityByName (std::string name) { for ( int t = 0; t < world->CountEntities(); ++t ) { Entity* e = world->GetEntity(t); if(e->GetKeyValue("name") == name) { return e; } } return 0; } 1 Quote
YouGroove Posted June 10, 2013 Posted June 10, 2013 Interesting code. I didn't know we could go that way with countEntities(). It seems lot more natural linear programming than using callbacks, i'll give it a try. Quote Stop toying and make games
neseir Posted January 7, 2014 Posted January 7, 2014 Hi Any tip how to do this in LUA ? Just installed the indie edition but have not worked with the LUA functions much. //Eirik Quote
Rick Posted January 7, 2014 Posted January 7, 2014 http://leadwerks.wikidot.com/wiki:entityindexer Quote
Rick Posted January 7, 2014 Posted January 7, 2014 This was just added today by an old member so it was in my head We are trying to get that wiki established as a place we can all go and contribute whatever we can. Quote
Admin Posted January 7, 2014 Posted January 7, 2014 You can also access the "entities" member of the world, which is just a standard C++ list. Quote
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.