Folders?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Afr0
Prole
Posts: 19
Joined: Mon Feb 22, 2010 9:01 am

Folders?

Post by Afr0 »

So I decided, after much deliberation, to try to go for a fully fledged tile-engine for my game. 'Space 1' didn't have a fully functioning level system, which was one feature I really missed. There is seemingly nothing wrong with my class, except that the Löve interpreter complains it can't load my tile image!
I've checked, and it's there!

Code: Select all

TileMap = {}
TileMapMT = { __index = TileMap } --This metatable will be attached to every created class instance.

TileMap.Tiles = {}
for i = 1,2 do
	TileMap.Tiles[i] = love.graphics.newImage("Tiles\\Tile"..i..".png")
end

function TileMap:Create()
	local NewInstance =
	{
		MapWidth = 20,
		MapHeight = 20,
		MapX = 0,
		MapY = 0,
		MapDisplayWidth = 14,
		MapDisplayHeight = 10,
		TileWidth = 32,
		TileHeight = 32
	} --The new instance
	setmetatable(NewInstance, TileMapMT)
	
	return NewInstance
end
I checked the documentation for love.filesystem, and it seems kind of confusing.

'This module provides access to Files in two places, and two places only:

The root folder of the .love-file. (Alternatively a directory).
The root folder of the write directory.
Each game is granted a single directory on the system where files can be saved through love.filesystem. These directories will typically be something like:

Windows: C:\Documents and Settings\user\Application Data\Love\game or %appdata%\Love\game
Linux: /home/user/.love/game or ~/.love/game
mac: /Library/Application Support/LOVE/game
Files that are opened for write or append will always be created in the save directory. The same goes for other operations that involve writing to the filesystem, like mkdir.

Files that are opened for read will be looked for in the save directory, and then in the game root folder (in that order). So if a file with a certain filename (and path) exist in both the .love-file and the save folder, the one in the save directory takes precedence.
'

Where exactly are files loaded from? I assumed it was from the root folder that 'main.lua' resides in?
I checked, and there is no 'Love' folder in my AppData directory.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Folders?

Post by bartbes »

It reads from both the .love (or the dir main.lua is in) and the save folder, the save folder is located in Application Data, but windows 7 changed paths for it, I believe you can find it in Roaming there.

As to why it doesn't work, well, use portable paths, so instead of \ (correctly escaped as \\ in your code) use /, and if you are using a .love make sure you use the correct case at it is case-sensitive.
Afr0
Prole
Posts: 19
Joined: Mon Feb 22, 2010 9:01 am

Re: Folders?

Post by Afr0 »

Ah, that worked!
May I ask what is the difference between \\ and /? I.E why should you use one and not the other?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Folders?

Post by Robin »

Afr0 wrote:May I ask what is the difference between \\ and /? I.E why should you use one and not the other?
/ is used by Unix, \ is used by MSDOS, because they already used / to precede command line arguments (where Unix uses - or --).

Luckily, Windows recognises / as well, so you can always use that.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests