Is there a way to check if EnemyBook or ItemBook is complete?

Hello everyone,


I'm making my game with multiple endings based upon what the player has collected, and one of those endings requires the EnemyBook and ItemBook (both made by sensei Yoji Ojima which I've gotten as part of the MV package) to be completed 100%.


Unfortunately, I can't find a clear way to make a conditional branch where the condition is the EnemyBook/ItemBook is fully written.


I suppose there's a way to do this with a variable and probably lots of editing on all my monsters, but if anyone already knows, please share the info. ;_;


I haven't found a plugin that does this, then again I haven't looked at any other bestiaries and such...
This is for EnemyBook


make event with script


var complete = 0;


for (i=1; i<=$dataEnemies.length+1; i++){


if ($gameSystem.isInEnemyBook($dataEnemies)){





complete +=1}





};





if (complete==$dataEnemies.length-1){





$gameSwitches.setValue(x,true)};





 





then make conditional event if switch(x) true





 





PS.. Don't forget change x to any number you like, and delete any empty enemy you have in database.





 





 
@mrcopra Apples!


Also, I tried it out and it didn't seem to work for me.


Do I need to change anything else, such as "var complete = 0"?


I don't have any experience in JavaScript... 😛


This is what I put in, Switch 20 is "Bestiary Complete":


EnemyBook.png
var complete=0;


for (i=1; i<$dataEnemies.length; i++){


if ($gameSystem.isInEnemyBook($dataEnemies)||$dataEnemies.name.length==0){





complete +=1}





};





if (complete==$dataEnemies.length-1){





$gameSwitches.setValue(x,true)};





 





try this, 
Still doesn't work, except this time I got the error message:


TypeError


Cannot read property 'length' of undefined
It worked for me, can you give me screenshot for the event?!

check.jpg
By the way you forgot


In first one


Just copy and paste then change x to any number
Comparing mine with yours, apparently two of the ""s were missing in the third line, so I replaced it with:


if ($gameSystem.isInEnemyBook($dataEnemies)||$dataEnemies.name.length==0){


And it seemed to work! 😀


On a minor note, could you make it compatible with the "<book: no>" function, which makes enemies with that notetag not appear in the enemy book?


Or even add something that subtracts a certain amount of enemies from the total needed (say I don't want 5 enemies in the book).


By default, your script also adds enemies that don't appear in the enemy book to the amount needed.


Thanks so much thus far, and would you like to be credited in my RPG game?


Edit: I just realized putting in [-i-] into this thread makes the post italic!


That probably explains my issues.


Double edit: Replacing "$dataEnemies" with "$dataItems" as well as replacing "isInEnemyBook" with "isInItemBook" makes the script work the exact same way, except with items and the item book!


Hurrah for compatibility! 😀
I made plugin for you, I hope it works perfectly.


it will ignore items and enemy with <book:no> and empty names.


Don't forget read help

View attachment Check_Items&Enemies.js
It does exactly what I need it to, thanks a lot!


Did you want to be in the credits of my RPG game as a script/plugin creator?
I don't mind 😉

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-to-check-if-enemybook-or-itembook-is-complete.65051/