Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var customMapFormat = {
- name: "PICO-8 Map Format",
- extension: "p8",
- write: function(map, fileName) {
- var layer = map.layerAt(0);
- var m = 'pico-8 cartridge // http://www.pico-8.com\n'
- + 'version 21\n'
- + '__lua__\n'
- + '-- Exported from Tiled\n\n'
- + '__gfx__\n\n'
- + '__map__\n';
- for (y = 0; y < layer.height; ++y) {
- for (x = 0; x < layer.width; ++x) {
- m += (layer.cellAt(x, y).tileId > 0)
- ? layer.cellAt(x, y).tileId.toString(16).padStart(2, 0)
- : '00';
- }
- m += '\n'
- }
- var file = new TextFile(fileName, TextFile.WriteOnly);
- file.write(m);
- file.commit();
- },
- }
- tiled.registerMapFormat("pico8", customMapFormat)
Add Comment
Please, Sign In to add comment