Ok, so the battle system I use, LeTBS (LeCode's Tactical Battle System) is supposed to have this feature where I can assign an enemy's troop index into an enemy cell's note box. At first, I thought the feature was broken, but upon further investigation, it seems that it's returning NaN under the hood. Let me explain...
I put <Enemy Cell: 0> & <Enemy Cell: 1> into the note box of 2 separate events on the map, which represents the enemies as visible/on map monsters. Normally, it should be <Enemy Cell> w/o the index mentioned, but that results in each event loading a random monster from the enemy troop. This sometimes (50% chance w/ troop size of 2) results in seeing monster A on the map, but then it turns out to be monster B once combat begins. Very immersion-breaking!
Anyway, I did some console logs and pinpointed the fault to a Regex in LeTBS.js. This is the relevant block of code:
The console logs yielded the following:
In short,
This is the RegExp btw:
I put <Enemy Cell: 0> & <Enemy Cell: 1> into the note box of 2 separate events on the map, which represents the enemies as visible/on map monsters. Normally, it should be <Enemy Cell> w/o the index mentioned, but that results in each event loading a random monster from the enemy troop. This sometimes (50% chance w/ troop size of 2) results in seeing monster A on the map, but then it turns out to be monster B once combat begins. Very immersion-breaking!
JavaScript:
BattleManagerTBS.createStartCells = function () {
this.getLayer("scopes").clear();
this._startCells = [];
$gameMap.events().forEach(function (eventObj) {
var x = eventObj.x;
var y = eventObj.y;
var note = eventObj.event().note;
var data = {};
if (note.match(/<Enemy Cell>/i)) {
data.type = "enemy";
} else if (note.match(/<Enemy Cell\s?:\s?(.+)>/i)) {
data.type = "enemy";
data.fixed = Number(RegExp.$1);
console.log(data.fixed); //testing...
console.log(data); //testing...
} else if (note.match(/<Actor Cell>/i)) {
data.type = "actor";
} else if (note.match(/<Actor Cell\s?:\s?(.+)>/i)) {
data.type = "actor";
data.fixed = Number(RegExp.$1);
}
if (data.type) {
var cell = new TBSCell(x, y);
cell._event = eventObj.event();
cell._positioningData = data;
this.createPositioningCell(data.type, x, y, cell);
this._startCells.push(cell);
if (!this._entitiesEvents[x])
this._entitiesEvents[x] = {};
this._entitiesEvents[x][y] = eventObj;
}
}.bind(this));
};
In short,
data.fixed is supposed to return the number that I put in <Enemy Cells: index>, where index should be a number. So if I write <Enemy Cells: 1> then the RegExp should return "1". However, I'm getting NaN...😔This is the RegExp btw:
else if (note.match(/<Enemy Cell\s?:\s?(.+)>/i)) {