Code: Select all
gd = require "gd"
Code: Select all
gd = require "gd"
There are a few things to consider. You say the dynamic library is in a compressed archive. The OS will never load a binary out of a Zip and the LÖVE binary loader does not automatically extract it for you. It's necessary to write the library to an actual file with love.filesystem (or the Lua IO, if you really have to ). The tricky part is where you need to place it.iconmaster wrote:I have, in my .love file, a library named 'gd.dll'.
[...]
it says no file was at '.\gd.dll', which happens to be exactly where gd.dll currently is!
This is what I was looking for, I believe. So, let's say I want to, on startup, move my dll from my .love file to the save directory. Is this possible, and if so, How would I wrangle love.filesystem to do this for me?Boolsheet wrote:Yes, LÖVE can load binaries.
There are a few things to consider. You say the dynamic library is in a compressed archive. The OS will never load a binary out of a Zip and the LÖVE binary loader does not automatically extract it for you. It's necessary to write the library to an actual file with love.filesystem (or the Lua IO, if you really have to ). The tricky part is where you need to place it.
Techincally, you could put the library anywhere and just modify the Lua binary loader search path (package.cpath) to make it look in the correct directory. This would be the easiest solution during development. Not so sure if that's going to give any problems when you release it.
The LÖVE binary loader only looks in one place. Well, actually two. For normal games it searches in the application data directory + '/love/'. This can be expressed as 'love.filesystem.getAppdataDirectory().."/love/"' or, on Windows, '%APPDATA%/love/'. The obvious problem is that you can't write there with the love.filesystem module. My guess is that this path is only meant for the development stage.
For fused release-mode games it searches in the save directory (love.filesystem.getSaveDirectory). This makes it very easy to load it. Just write it to the save directory and require it.
I'm using the GD library that came with my Lua distribution, which I believe is what you say, yes. I am using it so I can combine and manipulate multiple images together and then save them as a temporary tileset for a SpriteBatch. I am assuming it's probably is a poor tool for my job. I was looking just for a library to manipluate image files directly.Inny wrote:I'm assuming gd.dll is this: http://gnuwin32.sourceforge.net/packages/gd.htm
In which case, can I ask why this would be helpful? Maybe we can have a little discussion and get around even needing the dll in the first place, and keeping your game portable across every platform love supports.
Let's say you have a rot128 module like this.iconmaster wrote:This is what I was looking for, I believe. So, let's say I want to, on startup, move my dll from my .love file to the save directory. Is this possible, and if so, How would I wrangle love.filesystem to do this for me?
Code: Select all
#include <stdlib.h>
#include <lua.h>
static int rot128(lua_State * L)
{
size_t size, i;
const unsigned char * in = (const unsigned char *)luaL_checklstring(L, 1, &size);
unsigned char * out = malloc(size);
if (out == NULL)
return 0;
for (i = 0; i < size; i++)
out[i] = in[i] + 128;
lua_pushlstring(L, out, size);
free(out);
return 1;
}
#ifdef _WIN32
__declspec(dllexport)
#endif
int luaopen_rot128(lua_State * L)
{
lua_pushcfunction(L, rot128);
return 1;
}
Code: Select all
love.filesystem.setIdentity("binarytest")
local lib_ext
if love._os == "Windows" then
lib_ext = ".dll"
elseif love._os == "Linux" then
lib_ext = ".so"
end
if not lib_ext then
error("System apparently not Windows or Linux.")
end
if not love.filesystem.exists("rot128"..lib_ext) then
love.filesystem.write("rot128"..lib_ext, love.filesystem.read("_rot128"..lib_ext))
end
rot128 = require("rot128")
function love.load()
msg = "Hello world"
msg = rot128(rot128(msg))
end
function love.draw()
love.graphics.print(msg, 10, 10)
end
No, it is necessary to compile the library for all the platforms to make it work everywhere. It is possible, but can involve some headaches. Just deploying LÖVE alone is so much easier.Jasoco wrote:Unless there's such a thing as a universal DLL?
Yes Jasoco I agree with your concernings but if the library used is trully cross-platform you can also compile it as "dylib" for osx. Some game languages and frameworks usually can create their own universal dll. If I remember for example Pure Basic does something like that.Jasoco wrote:Also, using a DLL kind of defeats the purpose of cross-platform since OS X and Linux users may not be able to load them. DLL's are a Windows thing. Unless there's such a thing as a universal DLL?
Users browsing this forum: Amazon [Bot], Bing [Bot] and 10 guests