How can I make random variations?
Posted: Wed May 03, 2017 11:30 am
I had a mod idea, but as I've been writing it, I'm realizing more and more that this isn't possible.
The initial idea was to make random variations of different types of entities. For example, I would change the bounding box of various items so that they have different sizes, or I would change ratios on different recipes. This would force people to come up with new layouts.
However, the problem is that math.random() is deterministic, and at the data.lua stage, it is always seeded to the same value. This means that the variations I generate are always the same.
This makes sense, though: You don't want different prototypes every time you load the game, because you may want to load an existing game, which means that the prototypes should stay the same.
However, control.lua is too late: most of the properties I want to set are readonly. Bounding box is readonly, and all of the prototypes are readonly, and I don't see a way to reload a new prototype.
As it stands, the only way I see this being possible is by launching 5 different versions of the same mod, where each one calls math.random() a different number of times at the start, forcing the variations to be different.
Is there any other way to create random variations?
The initial idea was to make random variations of different types of entities. For example, I would change the bounding box of various items so that they have different sizes, or I would change ratios on different recipes. This would force people to come up with new layouts.
However, the problem is that math.random() is deterministic, and at the data.lua stage, it is always seeded to the same value. This means that the variations I generate are always the same.
This makes sense, though: You don't want different prototypes every time you load the game, because you may want to load an existing game, which means that the prototypes should stay the same.
However, control.lua is too late: most of the properties I want to set are readonly. Bounding box is readonly, and all of the prototypes are readonly, and I don't see a way to reload a new prototype.
As it stands, the only way I see this being possible is by launching 5 different versions of the same mod, where each one calls math.random() a different number of times at the start, forcing the variations to be different.
Is there any other way to create random variations?