Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use external library with love2d

I'm trying to use the luafun library with love2d. Running lua main.lua, however love . complains about the missing fun library.

I have installed luafun with luarocks.

like image 720
hgiesel Avatar asked Aug 30 '25 17:08

hgiesel


1 Answers

There's two options.

If you want to distribute whatever you're building, you almost certainly don't want users to install Lua, luarocks, etc. etc. - so the best way is to simply put any libraries into the folder that your game/program/… lives in. (If a library contains compiled things, you'll need to build per platform/OS and then you'll actually want a build process that spits out the various variants, but if it's all-Lua, there's no platform-specific stuff, so just copy it in.)

The other option (mostly for when you only need it to work on your machine) is to adjust package.path and then love will find things just fine. If you use LUA_INIT / LUA_PATH on your machine, Love ignores them but you can manually fetch & process them using os.getenv, dofile / load(code)() & friends. (As the very simplest special case of this, if luarocks is installed in the standard Lua search path, saying require "luarocks.loader" might be enough to get all luarocks-installed packages to work.)

like image 81
nobody Avatar answered Sep 02 '25 17:09

nobody