juur Posted January 6, 2015 Posted January 6, 2015 This is probably a dumb question, but how can I search for a random entity by name when I don't know it's parent? Is there a way to do root:FindChild() ? If so, how do I get the 'root' entity? On the documentation page for World it has std::list<Entity*> entities But I can't figure out how to access this from Lua. I have a number of different cameras, as childs to different entities, and I need to find the Camera entity so I can switch cameras. The cameras are not created in code so I have no handle. Quote
Averice Posted January 6, 2015 Posted January 6, 2015 Set the camera as a variable on the entity? That way you can just lookup the entities own camera from the entity itself. Quote
juur Posted January 6, 2015 Author Posted January 6, 2015 But how can I find that entity? How can I find arbitrary entities in code ... Quote
AggrorJorn Posted January 6, 2015 Posted January 6, 2015 Perhaps you find this useful: http://leadwerks.wikidot.com/wiki:entityindexer Quote
juur Posted January 6, 2015 Author Posted January 6, 2015 Thanks Aggror, that looks useful. I'm surprised that the core World class doesn't support ":getRoot()" or :FindChild(), seems to be a gap in the API. Quote
Rick Posted January 6, 2015 Posted January 6, 2015 I wouldn't use multiple cameras as who knows what a pain will happen there. I'd use pivots as location/rotation markers and just move your 1 camera around to those pivots. I think an "unsupported" way is world:FindEntity(""). Not sure what it'll do if the same name exists with more than 1. Quote
juur Posted January 6, 2015 Author Posted January 6, 2015 Thanks Rick, that does the trick and I agree multiple cameras is probably a bad thing. There also doesn't seem to be an API for the current camera either, the App.camera field indicated here isn't populated, are all the C++ style members in the documentation invalid for Lua? Quote
MarkusR Posted January 6, 2015 Posted January 6, 2015 maybe this help you World.ForEachEntityInAABBDo Quote PC : Win 10 Pro 64 Bit , 4x cores ~2 GHz , 8 GB RAM , AMD R7 265 2D : Photoline , Zooner Photo Studio 13 , Art Rage Studio 3.5.4 , Ashampoo Snap 7 , ... 3D : Shade 15 Basic , Carrara 8.5 & DAZ Studio 4.8 , Cheetah 3D 6.3.2 , Via Cad 8 Music : Samplitude Music Studio , Music Creator 7 IDE : Leadwerks Engine 3.x , Unity 5.x , (Unreal 4.8.x) , AGK v2.x , Construct 2 , (Clickteam Fusion 2.5) , ShiVa 1.9 , Game Maker Studio , MS Visual Studio .Net , Android Studio , Monkey , ...
AggrorJorn Posted January 6, 2015 Posted January 6, 2015 It is there under entities: http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/camera/ Quote
juur Posted January 6, 2015 Author Posted January 6, 2015 It is there under entities: http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/camera/ Not sure I follow? I can't see anything about entities on the page for the Camera class. maybe this help you World.ForEachEntityInAABBDo A bit of a hack but could work. Doesn't feel right to be (ab)using that sort of feature for such a basic 'global search' feature. Quote
shadmar Posted January 6, 2015 Posted January 6, 2015 You can also do this (not supported tho) : -- Get world self.world=World:GetCurrent() --Find camera by looping over every entity in self.world: if self.camera==nil then for i=0,self.world:CountEntities()-1 do --CountEntities is not a supported command if self.world:GetEntity(i):GetClass()==Object.CameraClass then self.camera=self.world:GetEntity(i) --GetEntity is not a supported command tolua.cast(self.camera,"Camera") System:Print(self.world:GetEntity(i):GetClassName()) break end end end Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB
juur Posted January 6, 2015 Author Posted January 6, 2015 <snip> I still have no idea what you're getting at, sorry. I know how to open the page on Camera, and I know Camera is derived from Entity, but how does that help? I still have no idea what you're getting at, sorry. I know how to open the page on Camera, and I know Camera is derived from Entity, but how does that help? Ahh, I meant there is no way (or i can't find one) of *getting the current camera* not *the camera isn't documented* Quote
MarkusR Posted January 7, 2015 Posted January 7, 2015 recursive GetParent should also bring you to root item from any entity, but i not tested myself. Quote PC : Win 10 Pro 64 Bit , 4x cores ~2 GHz , 8 GB RAM , AMD R7 265 2D : Photoline , Zooner Photo Studio 13 , Art Rage Studio 3.5.4 , Ashampoo Snap 7 , ... 3D : Shade 15 Basic , Carrara 8.5 & DAZ Studio 4.8 , Cheetah 3D 6.3.2 , Via Cad 8 Music : Samplitude Music Studio , Music Creator 7 IDE : Leadwerks Engine 3.x , Unity 5.x , (Unreal 4.8.x) , AGK v2.x , Construct 2 , (Clickteam Fusion 2.5) , ShiVa 1.9 , Game Maker Studio , MS Visual Studio .Net , Android Studio , Monkey , ...
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.