Page 1 of 2

[Solved] Adding a new module to Love, help!

Posted: Sat Jan 14, 2017 12:12 pm
by Mariscal
Hi all,

I'm adding a new C++ module to love, I've downloaded the sources and compiled the project, once I got that working I added my own module to love, but when building it, it doesn't seem to have my love.myModule

Things I've done so far:
  • - I copied how other modules are registered, so my module has an extern "C" int luaopen_love_myModule(lua_State *L)
    - Inside that function I end up calling return luax_register_module(L, w);
    - I have defined: #define instance() (Module::getInstance<MyModule>(Module::M_MYMODULE))
    - I'm adding my module in static const luaL_Reg modules[]
    - When int luaopen_love(lua_State *L) gets called, I can see myModule is being preloaded in the for loop for (int i = 0; modules.name != nullptr; i++)
    - To make sure I'm actually making changes to the source correctly, I changed the codename value to "Test" and when launching love.exe after building, it prints the value "Test" rather than "Super Toast"


I'm pretty sure I'm missing something as love.myModule is not inside love._modules when debugging my game with the love.exe I'm building.

Can someone point me in the right direction?
Thanks!

Re: Adding a new module to Love, help!

Posted: Sat Jan 14, 2017 12:15 pm
by raidho36
Try editing boot.lua file.

Re: Adding a new module to Love, help!

Posted: Sat Jan 14, 2017 12:28 pm
by Mariscal
raidho36 wrote:Try editing boot.lua file.
Thanks, I did it and now I added my module there, the question is, do I need to add this script folder next to my newly built love.exe?

Re: Adding a new module to Love, help!

Posted: Sat Jan 14, 2017 12:42 pm
by Mariscal
Do I also need to make changes in boot.lua.h ?

Re: Adding a new module to Love, help!

Posted: Sat Jan 14, 2017 12:45 pm
by Mariscal
NEvermind, found this old post: viewtopic.php?t=54754
Will give it a try!

Re: Adding a new module to Love, help!

Posted: Sat Jan 14, 2017 12:51 pm
by Mariscal
And working now, thanks a lot!

Re: Adding a new module to Love, help!

Posted: Sat Jan 14, 2017 1:03 pm
by raidho36
You're welcome! Ask any time. Also, what is the module you've added?

Re: Adding a new module to Love, help!

Posted: Sat Jan 14, 2017 1:21 pm
by bartbes
Please don't double, triple or quadruple post. Also, I'm fairly sure you didn't need to edit boot.lua, you could just have required your module manually.

Re: Adding a new module to Love, help!

Posted: Sat Jan 14, 2017 4:27 pm
by Mariscal
@raidho36: Steamworks integration
@bartbes: Sorry, should have probably edited my first reply! I'm also not very experienced with Lua, so just went for the C++ approach, and yes, I know I can also use luaJIT/FFI to achieve what I wanted, I've tried it and and by doing the same that steam provides in their C++ example some calls to their API crash, and without any documentation I was hitting a dead end.

Re: [Solved] Adding a new module to Love, help!

Posted: Sat Jan 14, 2017 4:33 pm
by raidho36
I don't think LuaJIT can pick up C++ binaries. To much wonky stuff is going on inside them, you pretty much need to compile both using identical tool chain for two C++ programs to couple.