Jump to content

running the thingoid methods


Rick
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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/

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :P

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...