Files
ModelTest20260714/GLM5.2/tools/gen_tileset_json.cjs
T

45 lines
1.5 KiB
JavaScript

// gen_tileset_json.js: produce assets/tilesets/tileset.json (Tiled tileset descriptor)
const fs = require('fs');
const COLS = 8, ROWS = 8, TW = 16, TH = 16, COUNT = 64;
const tiles = [];
for (let i=0;i<COUNT;i++){
tiles.push({ id: i, properties: [ { name:'collides', type:'bool', value:false } ] });
}
// collidable tiles: trees, bushes, walls, roofs (when solid), doors(no, passable),
// furniture (bed/counter/oven/shelf/table/chair/stool/well), objects (calendar/paper/chart/lamp/barrel/crate/fence/pillar)
// Indices per gen_tileset.lua order.
const collides = new Set([
7,8,9, // tree, birdTree, bush
10,11,12,13,// wall, wallTop, roof, roofEdge
18,19,20,21,22,23,24,25, // bed,counter,oven,shelf,shelfFull,table,chair,stool
26, // well
29, // whiteWall
31,32,33,34,// whiteDoor, whiteBed, whiteMonitor, whiteTable
38, // bench
40,41,42, // calendar, paper, chart
43,44, // fence
45, // lamp
47,48, // barrel, crate
59, // whitePillar
]);
for (const id of collides) { tiles[id].properties[0].value = true; }
const ts = {
columns: COLS,
image: 'tileset.png',
imageheight: ROWS*TH,
imagewidth: COLS*TW,
margin: 0,
spacing: 0,
name: 'tileset',
tilecount: COUNT,
tiledversion: '1.12.2',
tileheight: TH,
tilewidth: TW,
type: 'tileset',
version: '1.10',
tiles,
};
fs.mkdirSync('assets/tilesets', { recursive: true });
fs.writeFileSync('assets/tilesets/tileset.json', JSON.stringify(ts, null, 0));
console.log('Wrote tileset.json');