RMMV: new map at runtime

Rehwihola

Villager
Member
Joined
Mar 19, 2018
Messages
10
Reaction score
2
First Language
Finnish
Primarily Uses
RMMV
I 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));
 
Last edited:

Rehwihola

Villager
Member
Joined
Mar 19, 2018
Messages
10
Reaction score
2
First Language
Finnish
Primarily Uses
RMMV
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));
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,847
Messages
1,016,972
Members
137,561
Latest member
JaCrispy85
Top