XML Parser (for Tiled map files)

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
User avatar
VideroBoy
Party member
Posts: 102
Joined: Wed Mar 31, 2010 6:12 pm
Location: Canada

XML Parser (for Tiled map files)

Post by VideroBoy »

Hey guys, I'm back.

Anyway, I want to use Tiled to make the maps for my new project. I'm wondering if there's a Lua-based XML parser anyone would recommend.

The Lua Users wiki has a page on Lua XML parsers. Have any of you tried them with the map files created by Tiled?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: XML Parser (for Tiled map files)

Post by kikito »

If I remember correctly, Tiled exports directly to Lua (at least the Java version does)
When I write def I mean function.
User avatar
VideroBoy
Party member
Posts: 102
Joined: Wed Mar 31, 2010 6:12 pm
Location: Canada

Re: XML Parser (for Tiled map files)

Post by VideroBoy »

Aww. I want to use the nice shiny QT version. :cry:

Though, I suppose the Java version will do since Lua files would be easier to work with.

As an aside, Lua files are loaded by require-ing them. Is it possible to "unrequire" a file?
User avatar
Luiji
Party member
Posts: 396
Joined: Mon May 17, 2010 6:59 pm

Re: XML Parser (for Tiled map files)

Post by Luiji »

Use dofile() so that you can do it multiple times in the case that you want to load the same level again later on.

You can't unrequire(), so you should structure it so that the level file edits global variables that you can set to nil when you unload the level.
Good bye.
User avatar
Lap
Party member
Posts: 256
Joined: Fri Apr 30, 2010 3:46 pm

Re: XML Parser (for Tiled map files)

Post by Lap »

I've used LuaXML for saving map data. It works great and is really simple, but the more I look at what the map files look like in Lua vs XML the more I tend to think that there's no reason for not just having everything saved entirely in Lua.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 52 guests