Roland Posted December 17, 2014 Share Posted December 17, 2014 Is there any official way to find an entity in a loaded map using C++. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
gamecreator Posted December 17, 2014 Share Posted December 17, 2014 You can get the entities with the Load function when you load the map using a hook. Quote Link to comment Share on other sites More sharing options...
Roland Posted December 17, 2014 Author Share Posted December 17, 2014 Sounds great. Where is that documented. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
gamecreator Posted December 17, 2014 Share Posted December 17, 2014 Documentation at the top, Command Reference, Map link. Though you may need to search the forums for an example as the one there doesn't do this. 1 Quote Link to comment Share on other sites More sharing options...
Roland Posted December 17, 2014 Author Share Posted December 17, 2014 Yeah.. I must have been blind to miss that Thanks 1 Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Roland Posted December 18, 2014 Author Share Posted December 18, 2014 I tested the Map hook but it works partially. In the attached image you can see my hook which prints the name of each object sent to the hook by Map::Load. The only entity seems to be the light. The two boxes in the scene never shows up in the hook. Any suggestions ? According to the docs EVERY entity loaded will reach the hook Map::Load This function loads a Leadwerks map (*.map) file. Syntax static bool Load(const std::string& path, int flags=LoadScripts, const uint64_t fileid=0) static bool Load(const std::string& path, void hook(Entity* entity, Object* extra), Object* extra=NULL, const int flags=LoadScripts, const uint64_t fileid=0); Parameters path: the file path to load the scene from. hook: pointer to a function that will be called for each loaded entity in the scene. hookname: script function name that will be called for each loaded entity in the scene. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Rick Posted December 18, 2014 Share Posted December 18, 2014 Those are CSG I assume? The old mass or attached script on CSG strikes again . CSG gets collapsed if it doesn't have mass or an attached script which means they are no longer entities in LE's eyes. 1 Quote Link to comment Share on other sites More sharing options...
Roland Posted December 18, 2014 Author Share Posted December 18, 2014 Thanks a lot Rick. Will add mass to them then. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Roland Posted December 19, 2014 Author Share Posted December 19, 2014 Yes.. adding a mass solved that problem Quote Roland Strålberg Website: https://rstralberg.com 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.