I would like to ask you if someone else has a system like this in the working or has some thoughts about the subject.
its not the code, more the logic im asking for. who would this be done?
1. ok, you find random loot and there is a x% chance to find a key
2. the script scans the room you are currently in (big questionmark here) and looks for the nearest locked for
3. the script now spawns exactly the key that you require to open that door? (again big questionmark)
alternatively the game scans the whole level when starting and places keys in reachable tiles nearby the doors...

and while i am already on it, has someone tought about similar scripts like:
* random secret door generator (place them in the editor and let a script decide wich one is open/closed)
* random trap generator
yep, im the "random guy" - you can guess wich road of development im taking
