Page 1 of 1

Tiled Map Loading Help

Posted: Sun Jul 02, 2017 8:20 pm
by MetalMelnic
I am trying to import a tiled map in .lua format into love2d by following a tutorial series on the Simple-Tiled-Implementation library from GitHub. I attempted to get the map file from a root folder called maps, but that did not work so I moved the file to the sti folder in the library, it still did not work and both times the program crashed. The error message displayed was: init.lua: 44.attempt to call a nil value. I checked in the code and tried the included examples and they worked fine. I would be nice if I could get some help on this, or further clarification.

Link to Github:
https://github.com/karai17/Simple-Tiled-Implementation

Link to Lua Space:
http://lua.space/gamedev/using-tiled-maps-in-love

Thanks for your time.

Re: Tiled Map Loading Help

Posted: Mon Jul 03, 2017 8:20 am
by erasio
I think the important question is what does your code look like?

What value is nil? And why is it nil?

Nil basically means it doesn't exist at this point in time. So you must've skipped / overlooked one step that creates this variable or named it differently.

Without your code to look at it's impossible to say much more than that though but maybe it already helps?

Re: Tiled Map Loading Help

Posted: Mon Jul 03, 2017 3:52 pm
by MetalMelnic
Sorry, I forgot to add the example of my code.

Re: Tiled Map Loading Help

Posted: Mon Jul 03, 2017 5:59 pm
by erasio
A quick look into the sti file at the point of the error and we can see that this issue is caused when trying to load the file with love.filesystem.load().

So that's probably our input with the file location provided.

Since it's called with love.filesystem.load() it starts searching from the root folder. Not in STI/sti/.

So you'd need to provide that on load. "STI/sti/desert.lua".

Also your file has two dots. It's "desert..lua". You either have to remove one from the filename or add another dot for loading the file.

Cheers