How much space can you use in the settings extension?

I am using the settings extension to store grid configurations in my game. It’s basically a big number array. For every occupied grid cell, 4 number elements are added to the array. Then, I write it to wherever settings put it.

My question is, that how much space do I have?

@mmoskal mentioned this in another thread:

Does 16K mean 16 kilo bytes, or 16 kilo bits? 16 kilo bits is only 2048 bytes, which is a big difference than 16384 bytes.

And, will the settings extension throw an error if it can’t write to the flash? If it doesn’t, is it possible for settings to return the number of bytes written or -1 depending on success of write?

Thanks in advance.

It means kilobytes! not sure about the settings question, I can’t remember if it throws or just clears the storage when the settings quota is reached

1 Like

When you reach the quota it will clear the storage and reset with 920 panic code.

You can use buffer methods or msgpack.packNumberArray to pack your data efficiently.

2 Likes

Is it possible for the settings extension not to clear everything and just return, like -2 for storage full? Because I don’t think clearing everything doesn’t seem like a good fallback to me…

And how do I use it? Do I just pass an array into it and pass the return value into the settings write as number array function? And if I read it back from the settings, will I need to do some pre-processing before I get the original number array back?

Actually it seems write as number array is using msgpack.packNumberArray, so no need to use msgpack.packNumberArray.

You can file a feature request at https://github.com/microsoft/pxt-arcade to include settings.throwOnStorageFull() or something similar. I’m not sure exactly how that would work though.

1 Like