Tilemap Editor in LÖVE?
Tilemap Editor in LÖVE?
I'm currently trying to create a tilemap editor using LÖVE. I hated using things like Tiled etc cause I don't like having to shuffle files around and keep going in an out of different programs. Anyway I was wondering if anyone else has attempted something like this before? I plan on continuing with mine either way but it would be nice to see something to get some inspiration from.
- Hugues Ross
- Party member
- Posts: 115
- Joined: Fri Oct 22, 2021 9:18 pm
- Location: Quebec
- Contact:
Re: Tilemap Editor in LÖVE?
I think everybody and their aunt has tried that before, it's a pretty common topic. Anyway, here are a few relevant topics:
- viewtopic.php?f=14&t=94424
- viewtopic.php?p=244212#p244212
- viewtopic.php?f=3&t=88566
- viewtopic.php?f=5&t=82913
Re: Tilemap Editor in LÖVE?
Maybe some exporter to .Lua?royalepoe wrote: ↑Thu May 04, 2023 8:11 am I'm currently trying to create a tilemap editor using LÖVE. I hated using things like Tiled etc cause I don't like having to shuffle files around and keep going in an out of different programs. Anyway I was wondering if anyone else has attempted something like this before? I plan on continuing with mine either way but it would be nice to see something to get some inspiration from.
Code: Select all
/*
* Lua Exporter Plugin for Tiled Map Editor v1.0.0
*/
function luaExporterPlugin(map) {
var file = new TextFile(map.filename.replace(/\.[^/.]+$/, "") + ".lua", TextWrite);
var luaCode = "local map = {\n";
luaCode += "width = " + map.width + ",\n";
luaCode += "height = " + map.height + ",\n";
luaCode += "tilewidth = " + map.tileWidth + ",\n";
luaCode += "tileheight = " + map.tileHeight + ",\n";
luaCode += "layers = {\n";
for (var i = 0; i < map.layerCount; ++i) {
var layer = map.layerAt(i);
var layerName = layer.name;
var layerType = layer.__proto__.toString().replace(/\[object (.*)\]/, "$1").toLowerCase();
luaCode += "\t{\n";
luaCode += "\t\tname = \"" + layerName + "\",\n";
luaCode += "\t\ttype = \"" + layerType + "\",\n";
luaCode += "\t\tdata = {";
if (layerType === "tilelayer") {
for (var y = 0; y < map.height; ++y) {
luaCode += "\n\t\t\t";
for (var x = 0; x < map.width; ++x) {
var tile = layer.cellAt(x, y);
luaCode += tile.tileId + 1;
if (x !== map.width - 1 || y !== map.height - 1) {
luaCode += ",";
}
}
}
} else if (layerType === "objectgroup") {
for (var j = 0; j < layer.objectCount; ++j) {
var object = layer.objectAt(j);
var objName = object.name;
var objType = object.type;
var objX = object.x;
var objY = object.y;
var objWidth = object.width;
var objHeight = object.height;
luaCode += "\n\t\t\t{\n";
luaCode += "\t\t\t\tname = \"" + objName + "\",\n";
luaCode += "\t\t\t\ttype = \"" + objType + "\",\n";
luaCode += "\t\t\t\tx = " + objX + ",\n";
luaCode += "\t\t\t\ty = " + objY + ",\n";
luaCode += "\t\t\t\twidth = " + objWidth + ",\n";
luaCode += "\t\t\t\theight = " + objHeight + "\n";
luaCode += "\t\t\t}";
if (j !== layer.objectCount - 1) {
luaCode += ",";
}
}
}
luaCode += "}\n";
luaCode += "\t}";
if (i !== map.layerCount - 1) {
luaCode += ",";
}
luaCode += "\n";
}
luaCode += "}\n";
luaCode += "}\n";
file.write(luaCode);
file.commit();
file.close();
}
tiled.registerPlugin("LuaExporter", "Lua Exporter Plugin", luaExporterPlugin);
-
- Party member
- Posts: 356
- Joined: Wed Jul 03, 2013 4:06 am
Re: Tilemap Editor in LÖVE?
I made this forever ago...
https://github.com/pauljessup/greentea
It still works in the latest love, though I do have to add an example on how to use it...the dropbox link I had before doesn't exist anymore, lol. Next time I'll just add it to the repo
https://github.com/pauljessup/greentea
It still works in the latest love, though I do have to add an example on how to use it...the dropbox link I had before doesn't exist anymore, lol. Next time I'll just add it to the repo
Who is online
Users browsing this forum: Ahrefs [Bot] and 4 guests