Currently i am using separate modules for every single egg in my game which could get unorganized and messy and want to find another way to maybe put it all into one script and maybe clean it up a bit
My code for each module:
math.randomseed(tick())
local petModule = {}
petModule.pets = {
["Secret3"] = {
"Neon Unicore"
};
["Secret2"] = {
"Ultimate Frog"
};
["Secret1"] = {
"Party Bell"
};
["Legendary3"] = {
"Sweet Dragon"
};
["Legendary2"] = {
"Chocolate Cake"
};
["Legendary1"] = {
"PiƱata"
};
["Epic1"] = {
"Party Bear"
};
["Rare1"] = {
"Neon Bunny"
};
["Uncommon1"] = {
"Party Cat"
};
["Common1"] = {
"Neon Doggy"
};
}
petModule.rarities = {
["Secret3"] = 1;
["Secret2"] = 3;
["Secret1"] = 10;
["Legendary3"] = 100;
["Legendary2"] = 500;
["Legendary1"] = 2500;
["Epic1"] = 50000;
["Rare1"] = 300000;
["Uncommon1"] = 1646886;
["Common1"] = 3000000;
}
petModule.choosePet = function(player)
local luck = 1
local randomNumber = math.random(1, 5000000)
if randomNumber <= 1 * luck then
local rarity = "Secret"
local rarityTab = petModule.pets["Secret3"]
local chosenPet = rarityTab[1]
return chosenPet, rarity
elseif randomNumber <= 3 * luck then
local rarity = "Secret"
local rarityTab = petModule.pets["Secret2"]
local chosenPet = rarityTab[1]
return chosenPet, rarity
elseif randomNumber <= 10 * luck then
local rarity = "Secret"
local rarityTab = petModule.pets["Secret1"]
local chosenPet = rarityTab[1]
return chosenPet, rarity
elseif randomNumber <= 100 * luck then
local rarity = "Legendary"
local rarityTab = petModule.pets["Legendary3"]
local chosenPet = rarityTab[1]
return chosenPet, rarity
elseif randomNumber <= 500 * luck then
local rarity = "Legendary"
local rarityTab = petModule.pets["Legendary2"]
local chosenPet = rarityTab[1]
return chosenPet, rarity
elseif randomNumber <= 2500 * luck then
local rarity = "Legendary"
local rarityTab = petModule.pets["Legendary1"]
local chosenPet = rarityTab[1]
return chosenPet, rarity
elseif randomNumber <= 50000 * luck then
local rarity = "Epic"
local rarityTab = petModule.pets["Epic1"]
local chosenPet = rarityTab[1]
return chosenPet, rarity
elseif randomNumber <= 300000 * luck then
local rarity = "Rare"
local rarityTab = petModule.pets["Rare1"]
local chosenPet = rarityTab[1]
return chosenPet, rarity
elseif randomNumber <= 1646886 * luck then
local rarity = "Uncommon"
local rarityTab = petModule.pets["Uncommon1"]
local chosenPet = rarityTab[1]
return chosenPet, rarity
elseif randomNumber > 1646886 * luck then
local rarity = "Common"
local rarityTab = petModule.pets["Common1"]
local chosenPet = rarityTab[1]
return chosenPet, rarity
end
end
return petModule