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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Mariscal
Prole
Posts: 16
Joined: Sat Jun 25, 2016 4:51 pm
Location: London
Contact:

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

Post by Mariscal » Sat Jan 14, 2017 12:12 pm

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!
Last edited by Mariscal on Sat Jan 14, 2017 4:30 pm, edited 1 time in total.
Currently working on Breaking Fast, a competitive 2D "mario kart alike" racing game! Already passed steam greenlight, hopefully soon to be released! :D

User avatar
raidho36
Party member
Posts: 1833
Joined: Mon Jun 17, 2013 12:00 pm

Re: Adding a new module to Love, help!

Post by raidho36 » Sat Jan 14, 2017 12:15 pm

Try editing boot.lua file.

Mariscal
Prole
Posts: 16
Joined: Sat Jun 25, 2016 4:51 pm
Location: London
Contact:

Re: Adding a new module to Love, help!

Post by Mariscal » Sat Jan 14, 2017 12:28 pm

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?
Currently working on Breaking Fast, a competitive 2D "mario kart alike" racing game! Already passed steam greenlight, hopefully soon to be released! :D

Mariscal
Prole
Posts: 16
Joined: Sat Jun 25, 2016 4:51 pm
Location: London
Contact:

Re: Adding a new module to Love, help!

Post by Mariscal » Sat Jan 14, 2017 12:42 pm

Do I also need to make changes in boot.lua.h ?
Currently working on Breaking Fast, a competitive 2D "mario kart alike" racing game! Already passed steam greenlight, hopefully soon to be released! :D

Mariscal
Prole
Posts: 16
Joined: Sat Jun 25, 2016 4:51 pm
Location: London
Contact:

Re: Adding a new module to Love, help!

Post by Mariscal » Sat Jan 14, 2017 12:45 pm

NEvermind, found this old post: viewtopic.php?t=54754
Will give it a try!
Currently working on Breaking Fast, a competitive 2D "mario kart alike" racing game! Already passed steam greenlight, hopefully soon to be released! :D

Mariscal
Prole
Posts: 16
Joined: Sat Jun 25, 2016 4:51 pm
Location: London
Contact:

Re: Adding a new module to Love, help!

Post by Mariscal » Sat Jan 14, 2017 12:51 pm

And working now, thanks a lot!
Currently working on Breaking Fast, a competitive 2D "mario kart alike" racing game! Already passed steam greenlight, hopefully soon to be released! :D

User avatar
raidho36
Party member
Posts: 1833
Joined: Mon Jun 17, 2013 12:00 pm

Re: Adding a new module to Love, help!

Post by raidho36 » Sat Jan 14, 2017 1:03 pm

You're welcome! Ask any time. Also, what is the module you've added?

User avatar
bartbes
Sex machine
Posts: 4944
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Adding a new module to Love, help!

Post by bartbes » Sat Jan 14, 2017 1:21 pm

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.

Mariscal
Prole
Posts: 16
Joined: Sat Jun 25, 2016 4:51 pm
Location: London
Contact:

Re: Adding a new module to Love, help!

Post by Mariscal » Sat Jan 14, 2017 4:27 pm

@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.
Currently working on Breaking Fast, a competitive 2D "mario kart alike" racing game! Already passed steam greenlight, hopefully soon to be released! :D

User avatar
raidho36
Party member
Posts: 1833
Joined: Mon Jun 17, 2013 12:00 pm

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

Post by raidho36 » Sat Jan 14, 2017 4:33 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests