Craft Random Items with the Same Items

Hey, guys. I've got an issue.

I want to make a specific type of 'gem crafting' system.

Basically, there are four different colored gems of different sizes. However, when crafted, it results in a different gem with a different attribute.

For example, if one were to forge a gem with three small red crystals, they could get a gem that increases attack, but if they forge those three gems again, they could acquire a gem that gives you a whole new skill, instead.

Is there a script for this, already? And, if so, could somebody tell me where to find it?
Bump

Also, this needs to be moved to RGSS3 Script Requests. I just realized this...X'D
Bump
Bump

Original thread: https://forums.rpgmakerweb.com/threads/craft-random-items-with-the-same-items.84110/