AggrorJorn Posted March 27, 2013 Share Posted March 27, 2013 Does anybody know how to search entities that are loaded via map? LE2 LoadScene() gave back all entities but the current LoadMap function only returns a boolean. Quote Link to comment Share on other sites More sharing options...
Mumbles Posted March 27, 2013 Share Posted March 27, 2013 I didn't think LE 2 load scene returned anything, but once done, you could then do CountChildren() on the scene (everything it loaded was a child) and then use GetChild for each of these children to access each entity (GetChild returned a TEntity type) Obviously have no idea how this translates into Leadwerks 3 but in LE 2, LoadScene returned nothing. However there was a tutorial where it guided you through the process of writing a ProcessScene() function to get the children. Edit: Actually no, I lie, You passed it a string, it returned a TScene object, which you then called CountChildren() on Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
Rick Posted March 27, 2013 Share Posted March 27, 2013 I don't think we can at the moment, which is insane, but in another thread Josh was talking about ways of allowing this probably a week ago or so. Quote Link to comment Share on other sites More sharing options...
shadmar Posted March 27, 2013 Share Posted March 27, 2013 If you know your boundries, ForEachEntityInAABBDo maybe be used to index them all. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 27, 2013 Author Share Posted March 27, 2013 Well I am looking in to the entire scene. Of course the bounding box could be set to 10000000. But that would be very clumsy in my opinion. Quote Link to comment Share on other sites More sharing options...
shadmar Posted March 27, 2013 Share Posted March 27, 2013 Yeah I agree, Map should be an entity with loaded children. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
macklebee Posted March 27, 2013 Share Posted March 27, 2013 just looking at the LE3 documentation here, it appears a list is created for a world's entities... can you not access that list like how it was done in LE2? LE2: fw.main.world.entities or fw.main.world.meshes or fw.main.world.emitters...etc... 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rick Posted March 27, 2013 Share Posted March 27, 2013 After the map is loaded, the only thing I see under self.world is ambientlight (via the lua editor that shows the current state). Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 27, 2013 Author Share Posted March 27, 2013 Hey Macklebee! good to see you again. Yes we can access this list but there is nothing in there that can be used. In the image below I have loaded a scene which contains 1 csg brush and a directionalLight. If I iterate through this world list and try GetKeyName("DirectionalLight1") nothing is returned. Also note how the errors are displayed by the entity list. Quote Link to comment Share on other sites More sharing options...
tjheldna Posted March 28, 2013 Share Posted March 28, 2013 Hi Aggror, This may help you it iterates over the entities when the level is loaded. From there I can wrap the entities in classes and/or store them in a list... void StoreWorldPointsCallBack(Entity* entity, Object* extra) { std::string text = entity->GetKeyValue("name"); if(text.compare("playerSpawn") == 0) { TheGame->AddPlayerSpawnPoint(entity); } } //Load the map somewhere in your code if(Map::Load((const char*)(path), StoreWorldPointsCallBack)) { } 3 Quote Link to comment Share on other sites More sharing options...
Rick Posted March 28, 2013 Share Posted March 28, 2013 Woah! I guess that will teach us to look at the parameters section instead of the syntax section :/ http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/map/mapload-r510 I'll have to test this with Lua. Quote Link to comment Share on other sites More sharing options...
shadmar Posted May 14, 2013 Share Posted May 14, 2013 Rick, did you get this to work in lua? Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Josh Posted May 14, 2013 Share Posted May 14, 2013 Each scripted entity will have the Start() function, for Lua. That takes care of most usage. 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 May 15, 2013 Share Posted May 15, 2013 That's if you choose to attach a script to it. I don't think being able to loop over all loaded entities is much to ask really. Pretty common task. Quote Link to comment Share on other sites More sharing options...
shadmar Posted May 15, 2013 Share Posted May 15, 2013 Here's a way : function Callback(entity) App.entities[entity] = entity end function App:Start() self.entities = {} .. --Load the starting map local mapfilename=System:GetProperty("map","Maps/start.map") if Map:Load(mapfilename,"Callback")==false then return false end -- Find camera from map for k, v in next, App.entities do if v:GetClass()==Object.CameraClass then self.camera=v end end ... end Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Rick Posted May 16, 2013 Share Posted May 16, 2013 Thx Shadmar Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted May 17, 2013 Author Share Posted May 17, 2013 void StoreWorldPointsCallBack(Entity* entity, Object* extra) { std::string text = entity->GetKeyValue("name"); if(text.compare("playerSpawn") == 0) { TheGame->AddPlayerSpawnPoint(entity); } } //Load the map somewhere in your code if(Map::Load((const char*)(path), StoreWorldPointsCallBack)) { } Just a little detail for when you use a callback to iterate over all the entities loaded: Lights and models trigger the callback, but CSG objects by default don't. So if you would want to save CSG objects in to a class then you either have to attach a script or set a mass. 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.