Hey. I'm using this https://forums.rpgmakerweb.com/index.php?threads/procedural-maps-generator.83242/ plugin and I'd like to generate more maps at runtime as player progresses. Is it possible? How? Could RMMV JavaScript plugin or event create a data/Map###.json file or something?
RMMV: new map at runtime
Javascript/Plugin SupportI think I found a way to generate new maps at runtime. =)
Code:
//generate a new map
nextMapId = $dataMapInfos.length;
console.log("mapEdgeTransfer generating: ",nextMapName," id: ",nextMapId);
newMap = {"id":nextMapId,"expanded":true,"name":nextMapName,"order":nextMapId,"parentId":0,"scrollX":1716,"scrollY":1048.3636363636365};
$dataMapInfos.push(newMap);
//map data file
var path = require('path');
var fs = require('fs');
var sourceFile = path.dirname(process.mainModule.filename)+"/data/Map"+String(nextMapId-1).padZero(3)+".json";
var targetFile = path.dirname(process.mainModule.filename)+"/data/Map"+String(nextMapId).padZero(3)+".json";
fs.createReadStream(sourceFile).pipe(fs.createWriteStream(targetFile));
I noticed that $dataMapInfos gets reset when I save & quit & continue. I had to save it too:
Code:
//generate a new map
nextMapId = $dataMapInfos.length;
console.log("mapEdgeTransfer generating: ",nextMapName," id: ",nextMapId);
newMap = {"id":nextMapId,"expanded":true,"name":nextMapName,"order":nextMapId,"parentId":0,"scrollX":1716,"scrollY":1048.3636363636365};
$dataMapInfos.push(newMap);
//copy map file
var path = require('path');
var fs = require('fs');
var sourceFile = path.dirname(process.mainModule.filename)+"/data/Map"+String(nextMapId-1).padZero(3)+".json";
var targetFile = path.dirname(process.mainModule.filename)+"/data/Map"+String(nextMapId).padZero(3)+".json";
fs.createReadStream(sourceFile).pipe(fs.createWriteStream(targetFile));
//save $dataMapInfos file
targetFile = path.dirname(process.mainModule.filename)+"/data/MapInfos.json";
fs.writeFileSync(targetFile, JSON.stringify($dataMapInfos));
Original thread: https://forums.rpgmakerweb.com/threads/rmmv-new-map-at-runtime.93097/