jamesmintram Posted June 10, 2013 Share 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 Link to comment Share on other sites More sharing options...
YouGroove Posted June 10, 2013 Share 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 Link to comment Share on other sites More sharing options...
beo6 Posted June 10, 2013 Share 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 Link to comment Share on other sites More sharing options...
Rick Posted June 10, 2013 Share 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 Link to comment Share on other sites More sharing options...
beo6 Posted June 10, 2013 Share Posted June 10, 2013 since he wrote (in C++) it shouldn't be a problem. But good hint anyway. Quote Link to comment Share on other sites More sharing options...
Rick Posted June 10, 2013 Share Posted June 10, 2013 My bad. Missed that Quote Link to comment Share on other sites More sharing options...
jamesmintram Posted June 10, 2013 Author Share 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 Link to comment Share on other sites More sharing options...
YouGroove Posted June 10, 2013 Share 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 Link to comment Share on other sites More sharing options...
neseir Posted January 7, 2014 Share 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 Link to comment Share on other sites More sharing options...
Rick Posted January 7, 2014 Share Posted January 7, 2014 http://leadwerks.wikidot.com/wiki:entityindexer Quote Link to comment Share on other sites More sharing options...
neseir Posted January 7, 2014 Share Posted January 7, 2014 WOW That was quick !! Thanks !! //Eirik Quote Link to comment Share on other sites More sharing options...
Rick Posted January 7, 2014 Share 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 Link to comment Share on other sites More sharing options...
Admin Posted January 7, 2014 Share Posted January 7, 2014 You can also access the "entities" member of the world, which is just a standard C++ list. 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.