• Hey! Register here to create your account, engage with the community, and talk about what is new!

Is it possible to set the bounds of a list?

MrAwesomeOwl

New member
Overlord
Joined
Sep 26, 2020
Messages
6
Reaction score
2
I need to save a player's build as a game variable, and I would prefer to only have variables set when there are actually blocks instead of having a full list of effectively "air". However, I can't figure out how to have for example, only index 70 set on a list. Is this even possible or will I have to use dictionaries?
 

Vulcano

Forum adept
Overlord
Joined
Sep 11, 2020
Messages
243
Reaction score
65
I need to save a player's build as a game variable, and I would prefer to only have variables set when there are actually blocks instead of having a full list of effectively "air". However, I can't figure out how to have for example, only index 70 set on a list. Is this even possible or will I have to use dictionaries?
I would recommend using neither as the limit for either is 10k entries, which means 10k blocks. To save structures ideally I would use lists of texts that have been given a compressed string that contains the block data. The limit for texts is 2k characters so you could assign every used block a value in a dictionary at index 1 of the list so every block is some number of characters. You could also preset certain symbols for common blocks such as air, or have single digit codes set aside for the most common block that will not be used elsewhere so air takes up less space. You could also use certain symbols to represent amounts of air (Such as a period is one, comma is two, etc.). You should also set the size of the structure in this dictionary with some other name, only lowering the limit of unique blocks by one. On top of this, to store nbt data and container contents, you would need another dictionary set aside for just that. The key could be the coordinates and you could set the block data and such in the value. Im not the best dev so there are prob better options but this is the one I would personally use
 
Top Bottom