i am putting together a vehicle construction game that lets you place objects and configure them to create certain vehicles. i am thinking of different ways to save specific configurations for certain objects. for example, a motor might have a speed config that changes how fast it turns when the vehicle is spawned.
currently, the game uses value instances to control configurations of each individual object, though the number of instances will grow intensely once vehicles have up thousands of objects (this problem already exists.) i am currently developing a rewrite for the entire game, and i have two other ideas for storing configurations, and i can only think of one of them that actually helps me out.
the first method is attributes. it uses just one instance to store as much data as i want. however, i can’t create “sub-attributes” which is greatly required in my game. for example, a sub-attribute might be the unit at which a configuration is set to. so the motors speed is 1, but then a sub-attribute determines whether or not that is 1 rotation per minute, radians per second etc.
my last idea is using one modulescript per block that holds all of the configuration data and its subattributes. does anybody know if this will be too extreme on memory? though it will take up many less instances, will the amount of data it contains make too many problems? (assuming a player’s vehicle has 2000+ objects, which might mean up to 200 modulescripts depending on how many objects require functionality)
this is the format at which i would plan to store in a configuration module (an object could have up to 10 configurations at a time):
return {
speed = {
value = 1,
_unit = "rot/sec",
},
}
edit: i did forget to mention that specific units for a configuration are not the only types of data to be used in this sub-attribute way.
some configurations may need to have set min and max values. others might need to store extra bits of other information.
i know that this is a lot to read and many people might be discouraged to answer, but any suggestion or feedback helps. i am currently thinking of using modulescripts, but i just want to see what others think of this practice before i try it out.