Can't require() module?

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.
Post Reply
Zetty
Prole
Posts: 5
Joined: Wed Mar 25, 2009 6:50 pm

Can't require() module?

Post 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?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Can't require() module?

Post by bartbes »

love.filesystem.require("LuaXML.lua") should work, if it doesn't be sure to check capitalization.
Zetty
Prole
Posts: 5
Joined: Wed Mar 25, 2009 6:50 pm

Re: Can't require() module?

Post by Zetty »

It gets the first part, but then it can't find an existing file again:

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

Re: Can't require() module?

Post 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?
Zetty
Prole
Posts: 5
Joined: Wed Mar 25, 2009 6:50 pm

Re: Can't require() module?

Post 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)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Can't require() module?

Post 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)
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Can't require() module?

Post 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?
Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests