So, a while back, I was looking for a very simple enemy book. Just names in a category with a big description window and maybe a picture. No parameters, no gold, no XP, nothing like that.
I found one in this thread: https://forums.rpgmakerweb.com/index.php?threads/bestiary-encyclopedia.70085/ made by "Skotty TV" (who hasn't logged in within a few months, though I did try to contact them directly). The plugin code itself is here: [embedded media]
It's perfect except for the fact that if there are gaps in which enemies are represented, the plugin crashes the game. For example, if Enemies 0001, 0002, and 0003 all have categories and descriptions assigned to them, everything is fine. But if enemies 0001, 0002, and 0004 have descriptions, but not 0003, the game crashes. The error it gives is: "TypeError: Cannot read property 'cat' of undefined".
Is the plugin fixable? Any ideas on where I would start looking for the source of such an error?
Failing that, any suggestions for a different, simple enemy book with large description spaces?
Finding a simple enemy book or advice for fixing this one?
● ARCHIVED · READ-ONLY
-
-
line 598.
Code:if (note.match(/<STVSBB Desc>((.|\n)*?)<\/STVSBB Desc>/g)) desc = String(RegExp.$1); if (note.match(/<(?:STVSBB PIC):[ ](.*)>/i)) pic = String(RegExp.$1); if (note.match(/<(?:STVSBB CAT):[ ](.*)>/i)) { cat = String(RegExp.$1); var object = {"id":$dataEnemies[i].id, "cat":cat, "name":$dataEnemies[i].name, "desc":desc, "pic":pic, "discovered":false}; this.beasts[1][i] = object; }
property "cat" is only accessed in line 378
Code:if (beast.cat == this._cat) this._list.push(beast);
which depends on "beast" which is loaded by
Code:if (note.match(/<(?:STVSBB CAT):[ ](.*)>/i)) { cat = String(RegExp.$1); var object = {"id":$dataEnemies[i].id, "cat":cat, "name":$dataEnemies[i].name, "desc":desc, "pic":pic, "discovered":false}; this.beasts[1][i] = object; }
the problem is, if nothing matches that regular expression,
Code:if (note.match(/<(?:STVSBB CAT):[ ](.*)>/i)) {
this code
Code:doesn't runvar object = {"id":$dataEnemies[i].id, "cat":cat, "name":$dataEnemies[i].name, "desc":desc, "pic":pic, "discovered":false}; this.beasts[1][i] = object;
replace this chunk of code:
Code:if (note.match(/<(?:STVSBB CAT):[ ](.*)>/i)) { cat = String(RegExp.$1); var object = {"id":$dataEnemies[i].id, "cat":cat, "name":$dataEnemies[i].name, "desc":desc, "pic":pic, "discovered":false}; this.beasts[1][i] = object; }
with this
Code:if (note.match(/<(?:STVSBB CAT):[ ](.*)>/i)) { cat = String(RegExp.$1); } this.beasts[1][i] = {"id":$dataEnemies[i].id, "cat":cat, "name":$dataEnemies[i].name, "desc":desc, "pic":pic, "discovered":false};
watch the brackets. -
Thanks so much! You're awesome and you totally saved me =)
-
did it work? that was a blind shot TBH.
-
Sorry! I had to suddenly be away from my computer for a few days. Unexpectedly.
So, I tried your fix, but now the bestiary does not open at all. Using the bestiary command just closes the party menu. Which is strange! I do appreciate your trying to help, though. =) -
no idea why that'd happen.
my fix should only prevent it from crashing on a missing tag. -
Wait. I think I may just be dumb. I went back and tried again just for laughs and your fix worked this time. I must've just screwed up the positioning, or brackets, or removing the old stuff or... something. But I think it's working now! So, thank you again!no idea why that'd happen.
my fix should only prevent it from crashing on a missing tag.