Selecting items from a randomized list


If this should be in the code snippit forum, let me know or feel free to move it. :smiley:
I have been studying random arrays for things like name generators. But I’m trying to create something that does more than that for a game. I want to randomize items found when an area is searched with the items having a rarity of showing up, for example more likely to find a bloodstone than you are a diamond. Then the user chooses which of those items they are taking, the number they can take determined by the number they have in searching and then that selection gets logged and sent to another screen.

I haven’t been able to find any examples of how I would generate multiple random items who have different percentages of showing up. Would this be a function of its own or would the percentage be a value attached somehow to each item that the array would recognize?