Your issue arises from this block of code:
If C
For(L,0,C)
.Snip
End
End
I see two issues with this. First, because of how you add bullets, the first bullet is located at
L1+2, whereas this loop structure treats
L1 as the location of the first bullet. Secondly, this loop will run 0 times if C equals 0, but it will run C+1 times if C doesn't equal 0. For instance, if C equals 1, the loop will iterate for L equals 0 and 1, for two iterations total. This extra iteration in combination with reading data at
L1 that's not a bullet is what's causing the issues you're seeing.
Thankfully, the fix for this is really easy. It even allows you to completely remove the
If C block surrounding the for loop! Just change the lower bound of the for loop to 1.
For(L,1,C)
.Snip
End
Alternatively, the most optimized way to fix this is with your own loop structure.
C
While
→L
.Snip
L-1
End
And just for fun, here's my optimized version of the entire program. It's also attached.