After 6 hours, i consider the “meat” of the script to be done:
Spawning device has an unique ID
It runs a timer to add more dirt on the floor , runs a limited sensor for counting the dirt and stop adding when maximum is reached.
Each dirt spawned get the unique id and use it to rename itself.
Each dirt patch use sensor to find the dirt generator, read the configuration values from the generator name
Set the generator position as it’s origin and move itself at a random place in the generator’s declared radius.
When swept, the dirt patch is actually moved on the floor, and will refuse a move that will put it out of range of the generator control sensor.
Dirt rotate itself according to the angle it was swept.
Dirt assume random variation in “thickness” to reduce Z fighting in complanar faces.
Dirt suicide if it lose track of it’s generator.
That’s a lot for a patch of dirt 😀