I'm having trouble understanding it too. I wouldn't expect/ask you to do a thorough analysis, this is my problem to sort out and I feel quite bad that I've been bothering people with it. (Though I still can't trigger the issue, ugh!) The books, door and bookshelf all have basically the same conditional branches, if books carrying is 0, 1 or 2. The items each have their own common events when you view them, and the key one ends up overwriting the variable. If it makes that variable 3 or more it breaks the storeroom and the events in there only + or - variables rather than setting them so it is game over from there. Picking up the cheat sheet though, it's "show text" "show gab window" "play SE" "add item" and then a self switch. I think it's unlikely that Yanfly's Gab Window is messing with the variables, but there's really nothing in that which should cause issue. I did a run through on my editor version whilst checking the variables via the debug menu. The bookshelf works exactly as I want so I don't think it's a mistake in that, and yet the variable is never mentioned outside of that key issue. At this point, I'm feeling very defeated. I know there's a game ending bug in there, and even if it's not the one Judge DOOM encountered, I think it's fair enough to be disqualified. This bug that I can't find or understand, well, it's beaten me. This game wasn't good enough, and as I keep wasting my time searching and failing, it's really making me feel like I'm not good enough either, so I'd like to just nip it in the bud here. Maybe I'll come back to it later, but for now I'd like to forget that I ever tried. I really appreciate that you put the effort in for me though. I'm sorry I wasted your time, but thanks for trying to help anyway. :)
Viewing post in Lost Boy jam comments
If you can't fix it, here is an alternative: Remake it from scratch using the assets you have. It will probably take you less time to remake it than to fix it since you already know what events there will be and can plan ahead. Also, as a hint, make it so that the key and door only change the variable if used on the proper map (add in a conditional branch). Basically, any item that should only be used in one map, make sure it only has an effect on that one map. There is another way to do it as well, but it is more complicated so easier to make mistakes.