Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // UpperAutotiles.js
- //=============================================================================
- /*:
- * @plugindesc Allows you to use B-E tiles as autotile placeholders
- * @author Shaz
- *
- * @param Autotile Folder
- * @desc The img/ folder where autotiles will be saved.
- * @default autotiles
- *
- * @param Autotile Shift Region Start
- * @desc First region in a series of 48 to 'shift map' special autotiles
- * @default 200
- *
- * @help This plugin does not provide plugin commands.
- *
- * Notes:
- * This plugin does not affect the editor. You can specify a B-E tile to
- * behave as an autotile, but it will only do so while playing the game. The
- * editor will treat it as a regular B-E tile.
- * As the editor does not allow B-E autotiles, there is no shift-mapping. The
- * workaround is to use regions to override the default pattern selection.
- * If using two B-E 'autotiles' on the same tile, with a region id, the region id
- * will affect both tiles (two tile layers but only one region layer).
- * You cannot place A tiles on top of a B-E autotile, in the same way as you can
- * place A tiles on top of each other (eg fences, long grass). If you draw
- * with a B-E autotile and then try to draw with an A tile on top, the B-E tile
- * will be replaced.
- * All tile settings for the autotile will be EXACTLY as for the B-E tile -
- * passage, 4dir, ladder, bush, counter, damage floor and terrain tag. Passage
- * should be X, O or star. Strange things should be expected if you try to use
- * 4dir passage on B-E autotiles and fill an area with them.
- *
- *----------------------------------------------------------------------
- *
- * Compatibility: This plugin modifies (overwrites) the following functions:
- * TileMap._paintTiles
- * TileMap._drawAutotile
- * Plugins that alias either/both of these functions should be placed below
- * this plugin. There will be compatibility issues with other plugins that
- * overwrite either/both of these functions.
- *
- *----------------------------------------------------------------------
- *
- * HOW TO USE:
- * 1. Create autotile images
- * 2. Add autotile images to B-E tilesheet images
- * 3. Add notes to tileset to define B-E autotiles
- * 4. Map with B-E autotiles
- * 5. Adjust (shift-map) using regions
- *
- *----------------------------------------------------------------------
- *
- * IN MORE DETAIL:
- * STEP 1 - Create autotile images
- * . Autotile images are saved as individual files (one file per autotile), not
- * combined into tilesheets similar to the A1-A4 tiles.
- * . Each autotile image should follow the standard 2x2 or 2x3 autotile layout.
- * . For animated tiles, repeat the standard layout for as many frames as
- * required.
- * . Save the images in the folder specified in the plugin parameters (it is
- * recommended to NOT use the tilesets folder).
- *
- * STEP 2 - Add autotile images to the B-E tilesheet images
- * . Use your autotile image to create a 'representative' single tile to be used
- * on the tile palette (a 48x48 tile). This would normally be a combination of
- * the corner 24x24 pieces of the autotile, and shows how the autotile would look
- * if you used it on a single tile.
- * . Copy this image and paste it into your B-E tilesheet. It is recommended to
- * use some sort of indicator to show, in the editor, that this will be treated
- * as an autotile when the game is run. For example, a yellow star in the lower
- * left corner of the tile.
- *
- * STEP 3 - Add notes to tileset to define B-E autotiles
- * . For each 'autotile' tile on the B-E tabs, add a line to the tileset notes as
- * follows:
- * <autotile: tileId size frames filename>
- * TILEID is the tile id of the real tile on your tileset. To obtain this, you
- * can either count from the top left of the appropriate tab (tab B starts at 0,
- * C at 256, D at 512, and E at 768), or you can draw with that tile on a map
- * and add an event that sets a variable to the following script value:
- * $gameMap.tileId(x, y, 3)
- * where x and y are the positions of the tile. Then debug or show the variable
- * in a text box. This must be done BEFORE adding the note to the tileset.
- * SIZE is either 2x2 or 2x3
- * FRAMES is how many frames of animation (will be 1 for non-animated tiles)
- * FILENAME is the name of the file in the autotile folder, without the extension
- * Example: <autotile: 8 2x2 4 waterfall> will use the waterfall autotile, which
- * is a 2x2 autotile with 4 frames of animation, in place of tile 8 (the first
- * tile on row 2 of the B tab).
- *
- * STEP 4 - Map with B-E autotiles
- * . Just draw with your autotiles. In the editor, it will look like you're
- * placing individual tiles and they will not auto-shape like the A tiles do.
- * The magic happens when you play the game.
- * . Remember there are two layers of upper tiles, so you can place combinations
- * of regular tiles and 'autotiles' on top of each other.
- *
- * STEP 5 - Adjust (shift-map) using regions
- * . As the editor doesn't see these as autotiles, there is no shift-mapping
- * ability. To overcome this issue, you can use regions to override the
- * automatic pattern building and force a specific pattern to be drawn.
- * . Allocate a set of 6 full rows of regions for this purpose, and put the first
- * region id into the plugin parameter.
- * . To determine what region id you should use to override the pattern, create
- * a new map and draw a filled rectangle, 8 columns wide by 6 rows high, with
- * the B-E tile. Now grab the 6 rows of regions and draw over the tiles. Set
- * the starting position and play so you can see how the tiles will be changed.
- * Find the correct tile, then look back at your map to see what region id was
- * used. OR create an event that waits for a button press, then sets a variable
- * to the following script call:
- * $gamePlayer.regionId()
- * Then debug or show the variable in a text box.
- *
- */
- /*
- RESOURCE LIST - DO NOT MODIFY BELOW THIS LINE
- RESOURCE LIST - DO NOT MODIFY ABOVE THIS LINE
- */
- (function() {
- var parameters = PluginManager.parameters('UpperAutotiles');
- var autotileFolder = String(parameters['Autotile Folder'] || 'autotiles');
- var autotileShiftRegionStart = Number(parameters['Autotile Shift Region Start'] || 200);
- var autotileShiftRegionEnd = autotileShiftRegionStart + 47;
- /* Each autotile can make up to 48 different tile patterns. In RMXP you can
- see these by double-clicking on an autotile in the editor. The arrays
- below list the offset of the pattern, based on what surrounding tiles
- have the same tile ID. Only the 2x2 and 2x3 keys will be used in this
- plugin - I have not included waterfall type tiles as per the A1 layout.
- */
- Tilemap.AUTOTILE_GRAPH = {
- '2x2': [15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,11,11,11,11,11,11,
- 11,11,11,11,11,11,11,11,11,11,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,3,3,3,3,7,7,7,7,3,3,3,3,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,7,7,
- 7,7,7,7,7,7,6,6,6,6,6,6,6,6,7,7,7,7,3,3,3,3,6,6,6,6,2,2,2,2,13,13,
- 13,13,13,13,13,13,13,13,13,13,13,13,13,13,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,5,5,5,5,1,
- 1,1,1,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,8,8,8,8,8,8,
- 8,8,8,8,8,8,8,8,8,8,5,5,5,5,5,5,5,5,4,4,4,4,4,4,4,4,5,5,5,5,1,1,1,
- 1,4,4,4,4,0,0,0,0],
- '2x3': [46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,43,43,43,43,43,43,
- 43,43,43,43,43,43,43,43,43,43,42,42,42,42,42,42,42,42,42,42,42,42,
- 42,42,42,42,35,35,35,35,34,34,34,34,35,35,35,35,34,34,34,34,45,45,
- 45,45,45,45,45,45,45,45,45,45,45,45,45,45,33,33,33,33,33,33,33,33,
- 33,33,33,33,33,33,33,33,37,37,37,37,37,37,37,37,36,36,36,36,36,36,
- 36,36,23,23,23,23,22,22,22,22,21,21,21,21,20,20,20,20,44,44,44,44,
- 44,44,44,44,44,44,44,44,44,44,44,44,41,41,40,40,41,41,40,40,41,41,
- 40,40,41,41,40,40,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
- 19,19,18,18,17,17,16,16,19,19,18,18,17,17,16,16,39,38,39,38,39,38,
- 39,38,39,38,39,38,39,38,39,38,31,30,29,28,31,30,29,28,31,30,29,28,
- 31,30,29,28,27,25,27,25,27,25,27,25,26,24,26,24,26,24,26,24,15,14,
- 13,12,11,10,9,8,7,6,5,4,3,2,1,0]
- };
- function Autotile_Info() {
- this.initialize.apply(this, arguments);
- };
- Autotile_Info.prototype.initialize = function() {
- this.startingTileId = 0;
- this.imageSize = null;
- this.frames = 0;
- this.filename = null;
- };
- var _upperAutotiles_DataManager_onLoad = DataManager.onLoad;
- DataManager.onLoad = function(object) {
- _upperAutotiles_DataManager_onLoad.call(this, object);
- if (object === $dataMap) {
- this.replaceSpecialAutotiles();
- }
- if (object === $dataTilesets) {
- this.loadSpecialAutotileData();
- }
- };
- DataManager.loadSpecialAutotileData = function() {
- for (var i = 0; i < $dataTilesets.length; i++) {
- var tileset = $dataTilesets[i]
- if (tileset) {
- tileset.autotiles = {};
- tileset.autotileInfos = [];
- if (tileset.note !== undefined) {
- this.extractSpecialAutotileInfo(i);
- } else {
- tileset.tileIdMax = Tilemap.TILE_ID_MAX;
- }
- }
- }
- };
- DataManager.extractSpecialAutotileInfo = function(tilesetId) {
- var re = /<(autotile:)(\s*)(\d+)(\s*)(\d*x\d*)(\s*)(\d+)(\s*)(.*)>/g;
- var tileset = $dataTilesets[tilesetId];
- var startingTileId = Tilemap.TILE_ID_MAX;
- var autotileInfoId = tileset.tilesetNames.length;
- for (;;) {
- var match = re.exec(tileset.note);
- if (match) {
- info = new Autotile_Info();
- var tileId = Number(match[3]);
- info.startingTileId = startingTileId;
- info.imageSize = match[5];
- info.frames = Number(match[7]);
- info.filename = match[9];
- tileset.autotiles[tileId] = autotileInfoId;
- tileset.autotileInfos[autotileInfoId] = info;
- for (var i = 0; i < 48; i++) {
- tileset.flags.push(tileset.flags[tileId]);
- }
- startingTileId += 48;
- autotileInfoId++;
- } else {
- break;
- }
- }
- tileset.tileIdMax = startingTileId;
- };
- DataManager.replaceSpecialAutotiles = function() {
- var replacements = [];
- var tileset = $dataTilesets[$dataMap.tilesetId];
- var autotile = tileset.autotiles;
- // look at every tile for top two layers only (B-E tiles)
- for (var z = 2; z < 4; z++) {
- for (var x = 0; x < $dataMap.width; x++) {
- for (var y = 0; y < $dataMap.height; y++) {
- // is this a special tile that needs to be replaced by an autotile?
- var tileId = this.tileId(x, y, z);
- if (autotile[tileId] !== undefined) {
- var autotileInfo = tileset.autotileInfos[autotile[tileId]];
- // calculate new tile id
- var newTileId = autotileInfo.startingTileId;
- var regionId = this.regionId(x, y);
- // if there's a region in the expected range, just use that as an offset
- // - this allows the equivalent of shift-mapping
- if (regionId >= autotileShiftRegionStart && regionId <= autotileShiftRegionEnd) {
- newTileId += regionId - autotileShiftRegionStart;
- } else {
- // otherwise calculate the offset based on surrounding tiles
- var offset = this.isSameTile(x, y-1, z, tileId);
- offset = offset << 1 | this.isSameTile(x-1, y, z, tileId)
- offset = offset << 1 | this.isSameTile(x, y+1, z, tileId);
- offset = offset << 1 | this.isSameTile(x+1, y, z, tileId);
- offset = offset << 1 | this.isSameTile(x-1, y+1, z, tileId);
- offset = offset << 1 | this.isSameTile(x+1, y+1, z, tileId);
- offset = offset << 1 | this.isSameTile(x+1, y-1, z, tileId);
- offset = offset << 1 | this.isSameTile(x-1, y-1, z, tileId);
- newTileId += Tilemap.AUTOTILE_GRAPH[autotileInfo.imageSize][offset];
- }
- // and save it away for later replacement (need to do this as a separate step)
- replacements.push([x, y, z, newTileId]);
- }
- }
- }
- }
- // now go through and make all replacements in $dataMap
- var j = replacements.length;
- for (i = 0; i < j; i++) {
- var data = replacements[i]; // [x, y, z, newTileId]
- this.setTileId(data[0], data[1], data[2], data[3]);
- }
- };
- DataManager.isSameTile = function(x, y, z, tileId) {
- return (this.tileId(x, y, z) === tileId || this.tileId(x, y, 5-z) === tileId) ? 1 : 0;
- };
- DataManager.regionId = function(x, y) {
- return this.isCoordinateValid(x, y) ? this.tileId(x, y, 5) : 0;
- };
- DataManager.isCoordinateValid = function(x, y) {
- return x >= 0 && x < $dataMap.width && y >= 0 && y < $dataMap.height;
- };
- DataManager.tileId = function(x, y, z) {
- var width = $dataMap.width;
- var height = $dataMap.height;
- return $dataMap.data[(z * height + y) * width + x];
- };
- DataManager.setTileId = function(x, y, z, tileId) {
- var width = $dataMap.width;
- var height = $dataMap.height;
- $dataMap.data[(z * height + y) * width + x] = tileId;
- };
- ImageManager.loadAutotile = function(filename, hue) {
- return this.loadBitmap('img/' + autotileFolder + '/', filename, hue, true);
- };
- var _upperAutotiles_Spriteset_Map_loadTileset = Spriteset_Map.prototype.loadTileset;
- Spriteset_Map.prototype.loadTileset = function() {
- _upperAutotiles_Spriteset_Map_loadTileset.call(this);
- var tileset = this._tileset;
- if (tileset) {
- for (var i = tileset.tilesetNames.length; i < tileset.autotileInfos.length; i++) {
- this._tilemap.bitmaps[i] = ImageManager.loadAutotile(tileset.autotileInfos[i].filename);
- }
- this._tilemap.refresh();
- }
- };
- var _upperAutotiles_Tilemap_isVisibleTile = Tilemap.isVisibleTile;
- Tilemap.isVisibleTile = function(tileId) {
- return _upperAutotiles_Tilemap_isVisibleTile || tileId < $dataTilesets[$dataMap.tilesetId].tileIdMax;
- };
- Tilemap.isAnimatedUpperAutotile = function(args) {
- for (i = 0; i < args.length; i++) {
- var setNumber = this.getUpperAutotileSetNumber(args[i]);
- if (setNumber > 0 && $dataTilesets[$dataMap.tilesetId].autotileInfos[setNumber].frames > 1) {
- return true;
- }
- }
- return false;
- }
- Tilemap.getUpperAutotileSetNumber = function(tileId) {
- if (tileId >= this.TILE_ID_MAX) {
- return Math.floor((tileId - this.TILE_ID_MAX) / 48) + $dataTilesets[$dataMap.tilesetId].tilesetNames.length
- } else {
- return 0;
- }
- }
- /**
- * @method _paintTiles
- * @param {Number} startX
- * @param {Number} startY
- * @param {Number} x
- * @param {Number} y
- * @private
- */
- Tilemap.prototype._paintTiles = function(startX, startY, x, y) {
- var tableEdgeVirtualId = 10000;
- var mx = startX + x;
- var my = startY + y;
- var dx = (mx * this._tileWidth).mod(this._layerWidth);
- var dy = (my * this._tileHeight).mod(this._layerHeight);
- var lx = dx / this._tileWidth;
- var ly = dy / this._tileHeight;
- var tileId0 = this._readMapData(mx, my, 0);
- var tileId1 = this._readMapData(mx, my, 1);
- var tileId2 = this._readMapData(mx, my, 2);
- var tileId3 = this._readMapData(mx, my, 3);
- var shadowBits = this._readMapData(mx, my, 4);
- var upperTileId1 = this._readMapData(mx, my - 1, 1);
- var lowerTiles = [];
- var upperTiles = [];
- // only using tileId2 and tileId3 as 0 and 1 are for A tileset
- // var animatedUpperTile = Tilemap.isAnimatedUpperAutotile([tileId0, tileId1, tileId2, tileId3]);
- var animatedUpperTile = Tilemap.isAnimatedUpperAutotile([tileId2, tileId3]);
- if (this._isHigherTile(tileId0)) {
- upperTiles.push(tileId0);
- } else {
- lowerTiles.push(tileId0);
- }
- if (this._isHigherTile(tileId1)) {
- upperTiles.push(tileId1);
- } else {
- lowerTiles.push(tileId1);
- }
- lowerTiles.push(-shadowBits);
- if (this._isTableTile(upperTileId1) && !this._isTableTile(tileId1)) {
- if (!Tilemap.isShadowingTile(tileId0)) {
- lowerTiles.push(tableEdgeVirtualId + upperTileId1);
- }
- }
- if (this._isOverpassPosition(mx, my)) {
- upperTiles.push(tileId2);
- upperTiles.push(tileId3);
- } else {
- if (this._isHigherTile(tileId2)) {
- upperTiles.push(tileId2);
- } else {
- lowerTiles.push(tileId2);
- }
- if (this._isHigherTile(tileId3)) {
- upperTiles.push(tileId3);
- } else {
- lowerTiles.push(tileId3);
- }
- }
- var lastLowerTiles = this._readLastTiles(0, lx, ly);
- if (!lowerTiles.equals(lastLowerTiles) ||
- (this._frameUpdated && (Tilemap.isTileA1(tileId0) || animatedUpperTile ))) {
- this._lowerBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight);
- for (var i = 0; i < lowerTiles.length; i++) {
- var lowerTileId = lowerTiles[i];
- if (lowerTileId < 0) {
- this._drawShadow(this._lowerBitmap, shadowBits, dx, dy);
- } else if (lowerTileId >= tableEdgeVirtualId) {
- this._drawTableEdge(this._lowerBitmap, upperTileId1, dx, dy);
- } else {
- this._drawTile(this._lowerBitmap, lowerTileId, dx, dy);
- }
- }
- this._writeLastTiles(0, lx, ly, lowerTiles);
- }
- var lastUpperTiles = this._readLastTiles(1, lx, ly);
- if (!upperTiles.equals(lastUpperTiles) ||
- (this._frameUpdated && animatedUpperTile)) {
- this._upperBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight);
- for (var j = 0; j < upperTiles.length; j++) {
- this._drawTile(this._upperBitmap, upperTiles[j], dx, dy);
- }
- this._writeLastTiles(1, lx, ly, upperTiles);
- }
- };
- /**
- * @method _drawAutotile
- * @param {Bitmap} bitmap
- * @param {Number} tileId
- * @param {Number} dx
- * @param {Number} dy
- * @private
- */
- Tilemap.prototype._drawAutotile = function(bitmap, tileId, dx, dy) {
- var autotileTable = Tilemap.FLOOR_AUTOTILE_TABLE;
- var kind = Tilemap.getAutotileKind(tileId);
- var shape = Tilemap.getAutotileShape(tileId);
- var tx = kind % 8;
- var ty = Math.floor(kind / 8);
- var bx = 0;
- var by = 0;
- var setNumber = 0;
- var isTable = false;
- if (Tilemap.isTileA1(tileId)) {
- var waterSurfaceIndex = [0, 1, 2, 1][this.animationFrame % 4];
- setNumber = 0;
- if (kind === 0) {
- bx = waterSurfaceIndex * 2;
- by = 0;
- } else if (kind === 1) {
- bx = waterSurfaceIndex * 2;
- by = 3;
- } else if (kind === 2) {
- bx = 6;
- by = 0;
- } else if (kind === 3) {
- bx = 6;
- by = 3;
- } else {
- bx = Math.floor(tx / 4) * 8;
- by = ty * 6 + Math.floor(tx / 2) % 2 * 3;
- if (kind % 2 === 0) {
- bx += waterSurfaceIndex * 2;
- }
- else {
- bx += 6;
- autotileTable = Tilemap.WATERFALL_AUTOTILE_TABLE;
- by += this.animationFrame % 3;
- }
- }
- } else if (Tilemap.isTileA2(tileId)) {
- setNumber = 1;
- bx = tx * 2;
- by = (ty - 2) * 3;
- isTable = this._isTableTile(tileId);
- } else if (Tilemap.isTileA3(tileId)) {
- setNumber = 2;
- bx = tx * 2;
- by = (ty - 6) * 2;
- autotileTable = Tilemap.WALL_AUTOTILE_TABLE;
- } else if (Tilemap.isTileA4(tileId)) {
- setNumber = 3;
- bx = tx * 2;
- by = Math.floor((ty - 10) * 2.5 + (ty % 2 === 1 ? 0.5 : 0));
- if (ty % 2 === 1) {
- autotileTable = Tilemap.WALL_AUTOTILE_TABLE;
- }
- } else {
- var tileset = $dataTilesets[$dataMap.tilesetId];
- if (tileId >= Tilemap.TILE_ID_MAX && tileId <= tileset.tileIdMax) {
- setNumber = Tilemap.getUpperAutotileSetNumber(tileId);
- switch (tileset.autotileInfos[setNumber].imageSize) {
- case '2x2': autotileTable = Tilemap.WALL_AUTOTILE_TABLE; break;
- case '2x3': autotileTable = Tilemap.FLOOR_AUTOTILE_TABLE; break;
- }
- if (tileset.autotileInfos[setNumber].frames === 1) {
- bx = 0;
- } else {
- bx = this.animationFrame % tileset.autotileInfos[setNumber].frames * 2;
- }
- }
- }
- var table = autotileTable[shape];
- var source = this.bitmaps[setNumber];
- if (table && source) {
- var w1 = this._tileWidth / 2;
- var h1 = this._tileHeight / 2;
- for (var i = 0; i < 4; i++) {
- var qsx = table[i][0];
- var qsy = table[i][1];
- var sx1 = (bx * 2 + qsx) * w1;
- var sy1 = (by * 2 + qsy) * h1;
- var dx1 = dx + (i % 2) * w1;
- var dy1 = dy + Math.floor(i / 2) * h1;
- if (isTable && (qsy === 1 || qsy === 5)) {
- var qsx2 = qsx;
- var qsy2 = 3;
- if (qsy === 1) {
- qsx2 = [0,3,2,1][qsx];
- }
- var sx2 = (bx * 2 + qsx2) * w1;
- var sy2 = (by * 2 + qsy2) * h1;
- bitmap.blt(source, sx2, sy2, w1, h1, dx1, dy1, w1, h1);
- dy1 += h1/2;
- bitmap.blt(source, sx1, sy1, w1, h1/2, dx1, dy1, w1, h1/2);
- } else {
- bitmap.blt(source, sx1, sy1, w1, h1, dx1, dy1, w1, h1);
- }
- }
- }
- };
- // Add image files to required assets list, to ensure they are included
- // in a deployed project
- var _upperAutotiles_Scene_Boot_start = Scene_Boot.prototype.start;
- Scene_Boot.prototype.start = function() {
- _upperAutotiles_Scene_Boot_start.call(this);
- if (Utils.isOptionValid('test') && !DataManager.isBattleTest() &&
- !DataManager.isEventTest()) {
- // Read in this script
- var fs = require('fs');
- var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/');
- if (path.match(/^\/([A-Z]\:)/)) {
- path = path.slice(1);
- }
- path = decodeURIComponent(path);
- path = path + 'js/plugins/UpperAutotiles.js';
- if (fs.existsSync(path)) {
- var source = fs.readFileSync(path, { encoding: 'utf8' });
- source = source.split('\r\n');
- var resListStart = source.indexOf('RESOURCE LIST - DO NOT MODIFY BELOW THIS LINE');
- var resListEnd = source.indexOf('RESOURCE LIST - DO NOT MODIFY ABOVE THIS LINE');
- if (resListStart === -1 || resListEnd === -1) {
- console.log('ERROR - Unable to create resource list for UpperAutotiles.js');
- console.log('Please redownload the script and paste over your current version');
- } else {
- // remove previous list of resources
- source.splice(resListStart + 1, resListEnd - resListStart - 1);
- // build list of new resources
- var resources = [];
- $dataTilesets.forEach(function(tileset) {
- if (tileset) {
- tileset.autotileInfos.forEach(function(autotileInfo) {
- if (resources.indexOf(autotileInfo.filename) === -1) {
- resources.push(autotileInfo.filename);
- }
- });
- }
- });
- // add resource list to script
- var inspos = resListStart + 1;
- resources.forEach(function(filename) {
- var tag = '* @requiredAssets img/' + autotileFolder + '/' + filename;
- source.splice(inspos, 0, tag);
- });
- // and save the file
- source = source.join('\r\n');
- fs.writeFileSync(path, source, { encoding: 'utf8' });
- }
- }
- }
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment