Hi pichu, just a little thing without relation with scripts ; the saving part for polygons is a little corrupted.
I have checked all bytes and it seems that NPRE modifies a few bytes in the NSBMD file, only for the selected polygon. Also, Spiky's tool does not have the same format for NSBMD files, maybe because his tool uses a specific compression format.
I'm not sure if these particularities works on an real DS, so that's why i give my recommandations