Loot table problems

i am currently working on a loot table and it works sometimes, but sometimes it does nothing and im not sure why and am looking for help to fix the problem. for testing purposes i just have a light that turns on when that “loot” was hit and a debug.log to tell what loot was won, but sometimes it doesnt output anything and no lights turn on.

Your Total variable is going to be 100, the sum of the numbers in your table.

So, you are choosing a random number up to total, and checking to see if it is less then or equal to each value in the table.

That being said, any number select from 60 through total will never show as true in your if statement, and wont turn on the light/select the item.

Try reversing your logic. Make the if statement >= instead of <= As long at your numbers are in the table from greatest to least, (which they are) then this should get you the results you are looking for.

Here is a link to a discussion on using a weighted algorithm to select a random drop item.
It is only a minor change from what you are doing right now.

Hope this helps,