#I have a script to make rarities but it doesnt seem to work?

1 messages · Page 1 of 1 (latest)

lunar flicker
#

So i have a rng system setup and its kinda like this

    {Name = "Trash",     Weight = 70.0,  BasePrice = 1},
    {Name = "Common",    Weight = 18.0,  BasePrice = 6},
    {Name = "Uncommon",  Weight = 8.0,  BasePrice = 30},
    {Name = "Rare",      Weight = 3.0,   BasePrice = 150},
    {Name = "Legendary", Weight = 0.9,   BasePrice = 750},
    {Name = "Mythic",    Weight = 0.09,   BasePrice = 3750},
    {Name = "Divine",    Weight = 0.01,  BasePrice = 18750}

but the rarity doesnt seem to work properly?

local function rollForFish()
local roll = math.random() * 100
local counter = 0
local sizeMult = (math.random(100, 250) / 100)

for _, rarity in ipairs(FishData.Rarities) do
    counter += rarity.Weight
    if roll <= counter then
        local list = FishData.Fish[rarity.Name]
        if rarity.Name == "Trash" and math.random(1, 10) == 1 then
            list = FishData.Fish["RareTrash"]
        end
        local fishName = list[math.random(1, #list)]
        return {
            Name = fishName,
            Price = math.floor(rarity.BasePrice * sizeMult),
            Weight = string.format("%.2f", sizeMult * 5),
            Rarity = rarity.Name
        }
    end
end

end

but it doesnt seems to work so can someone help :D

gloomy badger
#

Any errors on output?

noble remnant
#

maybe make it print stuff like the outcome to see if it’s running properly

polar mantle
#

what is return supposed to do here

#

isnt it supposed to completely stop the for loop

opaque ferry
lunar flicker
#

yo hey guys my fault i figured out the problem

abstract waspBOT
#

studio** You are now Level 1! **studio