MZ Help replenishing pieces in my Match3/Drop Game

Ok so I'm guessing I've coded some things majorly incorrect.

Most everything works flawlessly except replenishing the pieces that respawn to drop in to fill in the empty spaces.
..which leads me to believe the way I've coded the whole engine might even be flawed.

Tried a number of things and kind of had it working but still not quite...

Hope someone can make sense out of this and help get it working. 😅

...could really use some help getting the respawn pieces to work properly.
Where the call is to the replenish code function is currently commented out.
It's in 2 spots that have the comment TODO located above the call to the replenish code function.
Lines 1267 & 2321

Anyways... here is the plugin I'm making:
CTB_DropGameMZ (v0.10): Click Here to Download

To start the game scene use the following code:
JavaScript:
CTB.DropGame.Play()

This is an example of what gameplay is currently:
Spoiler: Demo Video (Without replenish pieces code)


Spoiler: Demo Video (With replenish code - Extremely Broken)

As you can see the current replenishment code is very broken and has many issues.
Thanks in advance for taking the time to even look into this issue for me & any help 🙂
OK, It's now time for me to pull out my universal engine knowledge that doesn't actually span that far.

I don't know JavaScript, but usually me spouting out general knowledge of why things usually don't work helps.

I assume you're using an array for the board. This is probably very wrong, but what I can envision is if you take the value of each column, and check how many empty slots there are, you can then move down the appropriate amount of pieces onto the board. So, say if column 3 has 2 pieces missing when you have made a match, you'd then run a for loop on the amount of pieces missing.

Original thread: https://forums.rpgmakerweb.com/threads/help-replenishing-pieces-in-my-match3-drop-game.151009/