World file to lua

Hi,
I ´m working on a Tiled to Love2d tool.
You export lua maps from Tiled as (csv data)
Then the tool reads lua maps to draw tiles
And animations…

Would it be possible to add a feature in Tiled to create world files in Lua too?

I mean to be able to load all maps of a world in a row without having to convert json.

That’s great, but are you aware of existing solutions for using Tiled maps with Love2D? There was Advanced Tiled Loader (no longer maintained) and the Simple Tiled Implementation, which still seems to be developed. Is your solution taking a different approach?

It would certainly be possible to add. It could either by explicitly building an exporting feature for Worlds and allowing plugins to hook into this, as done for maps and tilesets. Or, what I’d probably prefer at first, to implement the currently missing JavaScript API to access loaded worlds such that you can implement a “Export World as Lua” action yourself.

Thank you for the quick answer.

I made this tool during a game jam in order
To make my game.
Then i saw Atl and simple Tiled implementation.

So i have a different approach as you said.
The tool is doing the job to import assets
Once you saved Tiled’s lua maps into the Love2d’s project directory.

So, for now, you have to type map names
In a map editor menu and it load them in the game.

But i saw that your world editor is very useful
And even more in the latest release.
So loading worlds would be great.

I ´m trying to convert world json with lua io.read("*all") and gsub function, so quoted variable names should be the hardest part to substitute.

There’s an earlier version here, a lot of things have changed (no need to restart love2d) but just to show what i mean:

Ps: i don’t know JavaScript, for now i learn lua since two years and i have some knowledge of c# , just to say that i ´m not a professional yet, i hope one day…

Why not use something like json.lua or luajson?

Though they have their differences, JavaScript and Lua have more in common than their rather different syntax suggests. But there’s definitely more to learn about JavaScript than Lua (which I think says something good about Lua).

Thank you for the links, i already checked
json.lua yesterday and it could do the job.
As modules, it’s inside the project so i ´ll
give it a try even if it adds more files to the tool.

Oh and thank you for this great tool that is Tiled, keep going :wink:

1 Like

Hi again,
Since i know the world variable names, i was able to
Write a module to convert Tiled world files into lua module.

Here is the link on github if someone is interested: