Page 1 of 1

Can't require() module?

Posted: Sat Mar 28, 2009 7:53 am
by Zetty
I kinda feel bad for starting another topic, but that's what the forums are for, eh?

Anyway, I'm trying to use the LuaXML module. I've tried require("LuaXML") and love.filesystem.require("LuaXML") and also tried adding .lua to the end of those, but I'm still getting errors.

Here's what I get if I try just "LuaXML"
no field package.preload['LuaXML']
no file '.\LuaXML.lua'
...
Now, I know I have ./LuaXML.lua since everything's in one directory, so I'm not sure what's wrong. :(

(If I use "LuaXML.lua" it looks for LuaXML_lib.lua which isn't there, but LuaXML_lib.dll is there, so I'm thinking that's not the way to go...)

Suggestions?

Re: Can't require() module?

Posted: Sat Mar 28, 2009 8:57 am
by bartbes
love.filesystem.require("LuaXML.lua") should work, if it doesn't be sure to check capitalization.

Re: Can't require() module?

Posted: Sat Mar 28, 2009 4:02 pm
by Zetty
It gets the first part, but then it can't find an existing file again:

Image

Re: Can't require() module?

Posted: Sat Mar 28, 2009 4:08 pm
by bartbes
Correct, you should change the require statement in LuaXML.lua so it uses the correct require statement. (it is using standard lua-style atm)

EDIT: love.filesystem.require("LuaXML_lib.dll")
Though I don't know how LÖVE handles dlls. And you are aware this makes your game windows-only?

Re: Can't require() module?

Posted: Sat Mar 28, 2009 4:31 pm
by Zetty
bartbes wrote: EDIT: love.filesystem.require("LuaXML_lib.dll")
Though I don't know how LÖVE handles dlls. And you are aware this makes your game windows-only?
I guess that would make sense. Sadly, I'm not that troubled making it windows-only. :\

Your suggestion didn't work, but after some fiddling around, I discovered that it would work if LuaXML_lib.dll was in the installed directory (C:\Program Files\LOVE).

So I investigated some more:
Here's what I've found when using WinXP and Windows Explorer: If I drag my folder to love.exe the working directory is C:\Windows. However, if I right-clicking my project folder and using "Send To" or drag the folder to a shortcut of the exe, the directory is C:\Program Files\LOVE.

Furthermore, when creating a .love or .exe, the working directory is wherever you begin to run the file, so that's where you've gotta have your dll's and what not.

Which leads to two questions:
1. Is there a way to make my project folder the working directory? It would be nice to have the same behavior during development as well as release.
2. If I included LuaXML_lib.o in the .love would it work under Linux? (I also have LuaXml.cdr, but I've never seen .cdr under Linux)

Re: Can't require() module?

Posted: Sat Mar 28, 2009 7:06 pm
by Robin
If you put the following in a Registry file, it should create a "Love this" menu item for folders in Windows Explorer.

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\love]
@="&Love this"

[HKEY_CLASSES_ROOT\Folder\shell\love\command]
@="\"C:\\Program Files\\LOVE\\love.exe\" \"%1\""

EDIT: you run .reg files at your own risk. If anything goes wrong: it's not my fault. (If you liked the above .reg file, you may also be interested in the latest version of FORKBOMB.BAT)

Re: Can't require() module?

Posted: Sat Mar 28, 2009 7:33 pm
by bartbes
Zetty wrote:2. If I included LuaXML_lib.o in the .love would it work under Linux? (I also have LuaXml.cdr, but I've never seen .cdr under Linux)
You have to compile to .so, in linux the compiler options are easy, use the -shared flag.

And, where did you put that second require statement I posted?