Page 1 of 1

Error: launching the .love in same directory than love.exe

Posted: Sun Mar 20, 2011 9:48 pm
by tetrisDev
Hi,

I've started to develop an original game call Tetris with love !
The game run correctly if I launch the game like that from the command prompt:
../love.exe tetris.love (in this case the file is in the same directory than love.exe
or like that
../love.exe ../tetris.love (here in the sub directory tetris)
I launch it from the directory tetris.
(windows XP SP3)
directory structure is:
love
love\tetris
love\tetris\resources
love\tetris\txt


but If I launch it
love.exe tetris.love or drag the .love in the love.exe

I get an error it seems that the "system" is unable to read or find a text file in the subdirectory txt.
I use the lua library libSaveTableToFile

Error: [string "menu.lua"]:9: attempt to get length of field 'menuItems' (a nil
value)
stack traceback:

the call is :
self.menuItems = table.load("txt/menu_"..lang..".txt")
self.nbItems = #self.menuItems


I've try to put the directory "txt" in the same directory than love.exe without success.

Any help are very welcome. I'm :cry:

Thank you.

Re: Error: launching the .love in same directory than love.e

Posted: Sun Mar 20, 2011 10:22 pm
by Taehl
Looks like you have the wrong kind of slash. You need to keep your filepaths UNIX-style.

Re: Error: launching the .love in same directory than love.e

Posted: Sun Mar 20, 2011 10:59 pm
by tetrisDev
Thanks for your answer.
I try to put the file in the root and call it like that

self.menuItems = table.load("menu_en.".txt")

but I get the same error.
I use the "/" everywhere in the code not the "\". I also take care of the case.

I add this code with the file in the same directory then main.lua

filename="menu_"..lang..".txt"
f = io.open(filename, "r")
if (f ~= nil) then
local t = f:read("*all")
print(t)
f:close()
else
print("Cannot open", filename)
end

It's still not work when I drag and drop the .love in the love.exe
But I've the message Cannot open... in the console.

I've do another test and putting the directory txt in the same folder than love.exe and it's work if I lauch it by command line
love.exe tetris.love
But not if I drag and drop...