Rick Posted February 5, 2010 Share Posted February 5, 2010 Has anyone tried running thingoid lua functions from C++? For example the object:Update() method for a specific thingoid? Just curious because I'd like to create an object:Initialize() method that I run on all the objects in my own C++ method. I do this in the editor main lua game file just fine but would like to also have it run from my C++ exe. Quote Link to comment Share on other sites More sharing options...
Canardia Posted February 5, 2010 Share Posted February 5, 2010 Windmill works fine in C++. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Rick Posted February 5, 2010 Author Share Posted February 5, 2010 Yeah, I guess what I'm asking is could I call the Windmills object:Update() method myself from C++? That's an example and obviously I wouldn't need to do that but if I could then I could call other functions in lua that way, like an object:Initialize() method that I create for an object. Quote Link to comment Share on other sites More sharing options...
Canardia Posted February 5, 2010 Share Posted February 5, 2010 So far Josh has implemented only 4 lua C API commands in LE. You would need the lua_call command (and a few others to support it) to call Lua functions from C++: http://www.lua.org/manual/5.1/manual.html#lua_call'>http://www.lua.org/manual/5.1/manual.html#lua_call See the whole list of Lua C API commands here (those which are named lua_xxx): http://www.lua.org/manual/5.1/ Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Rick Posted February 5, 2010 Author Share Posted February 5, 2010 Well I tried using lua in my C++ but I wasn't able to get things to work because Josh made his lua functions the same name and normal lua complains because Josh has the first parameter to his functions being BP. If you have normal lua functions working along side the LE lua commands I'd love to see how you did it. Quote Link to comment Share on other sites More sharing options...
Canardia Posted February 5, 2010 Share Posted February 5, 2010 That sounds like it would be better to rename the LE lua commands so that they don't collide with the official Lua C API commands when the Lua C API is used directly from C++. Another way would be to embed the C headers into a namespace, but that would make it another step away from real C. There are one or two users who want to have the procedural C++ headers to be real C, which would require the references to be removed from the parameters. Removing references would also slow down the engine, but I guess C programmers don't care about speed so much as real C++ programmers do Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Rick Posted February 5, 2010 Author Share Posted February 5, 2010 That's right lua is open source. So I could get the source and put a namespace around it. That's a pain that I have to do that but doable. Thanks! Quote Link to comment Share on other sites More sharing options...
Canardia Posted February 6, 2010 Share Posted February 6, 2010 I think I will propose to Josh to have the C header lua functions renamed to upperinitials, like Lua_PushObject() instead of lua_pushobject(). Then the pure C coders are happy too, since I don't use namespaces. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Rick Posted February 6, 2010 Author Share Posted February 6, 2010 I think that would be best. There is no real reason to use the same function names as a popular library. No sense in rewriting all the lua methods. Just the ones where he does something extra under the hood. Quote Link to comment Share on other sites More sharing options...
Rick Posted February 6, 2010 Author Share Posted February 6, 2010 The sooner this could be done the better. It looks like it might be a pain to wrap lua in a namespace. 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.