TheConceptBoy Posted January 2, 2019 Share Posted January 2, 2019 Good day everyone and happy new year! The two questions in the title are related. From what I understand if you are using the leadwerks editor with Lua, you have the ability to create objects that have logic attached to them. So you can create a crate that makes a bell sound and explodes while spawning confetti particles when you get close to it. And then you can drag and drop as many of those boxes in your level as you want. In this case they act like instances of a class and I'm very familiar with it this sort of logic Game Maker studio. Now when using the C++ API, how does one go about creating these classes AND be able to place them in the level editor as instances? On another note. Say you placed a wall mesh in the editor and a some point in the level you need to delete that instance in C++, how do you go about grabbing the id of that mesh to delete it in C++ code? Thanks. Quote Link to comment Share on other sites More sharing options...
Josh Posted January 2, 2019 Share Posted January 2, 2019 Use the name and World::FindEntity(). 1 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...
TheConceptBoy Posted January 2, 2019 Author Share Posted January 2, 2019 3 minutes ago, Josh said: Use the name and World::FindEntity(). Ah, that's how you find the exiting entities placed in the level editor. So for the other one? Say I program an AI behavior in C++, I can turn it into a class and have the class load the model in the class constructor. How can one then use the leadwerks editor to place these class objects in the level, even if that's possible? I can certainly find ways around it, like create a dummy marker object that I place in the editor, then use the FindEntitiy on level startup and replace all dummy markers with C++ Class instances of the object with code. Just want to see if there is more than one way to get that done. Thanks Quote Link to comment Share on other sites More sharing options...
Josh Posted January 2, 2019 Share Posted January 2, 2019 If you use Lua there is a nice prescribed way to do things. If you use C++ you are kind of on your own when it comes to that type of thing. I might have something in the new engine that will auto-generate a bit of C++ code to attach actor objects to entities. 1 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...
TheConceptBoy Posted January 2, 2019 Author Share Posted January 2, 2019 Just now, Josh said: If you use Lua there is a nice prescribed way to do things. If you use C++ you are kind of on your own when it comes to that type of thing. I might have something in the new engine that will auto-generate a bit of C++ code to attach actor objects to entities. Oooo the attach thing would actually be great. If anything I think I ended up answering my own question above with the dummy object and a piece of code that replaces each dummy with a C++ class object. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted January 2, 2019 Share Posted January 2, 2019 I'm curious why a dummy object is needed. If you place a crate in the editor, can't you just code for that directly? Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted January 2, 2019 Author Share Posted January 2, 2019 Just now, gamecreator said: I'm curious why a dummy object is needed. If you place a crate in the editor, can't you just code for that directly? In Lua, yes. There's a code editor built into Leadwerks. I'm not sure if that's also possible with C++ though. Can you do the same with c++ in the editor? Perhaps you'd know more on the subject. Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted January 2, 2019 Author Share Posted January 2, 2019 From what I know, in C++ you have to create a class of the crate if you want it to have logic and to spawn multiples of them and then via C++ you have to create the instances using pointers. In the constructor of that class you then load up the 3D model and other assets pertaining to that crate object. That is my logic of it. I'm not sure IF you can even attach a c++ code snippet to an object in leadwerks in the first place. Perhaps I'm over thinking it and LW already offers a system in palce. I know it does for Lua but I'm working in C++. The dummy object is basically my solution since as far as I know, you cannot physically place/create objects in the LW editor that are are instances of a class that was declared in C++ using Visual Studio. Or maybe you do and I'm an idiot. 1 Quote Link to comment Share on other sites More sharing options...
Rick Posted January 3, 2019 Share Posted January 3, 2019 I describe how you can do this here. 2 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.