Introducing LootR! A simple Percentage and Weight based loot table module!

LootR

Hello! I have made a loot table module that supports both percentage and weight based tables.

Link to module

How to use

First create a loot table like this:

local LootTablet = {
	
	Type = "Percentage", --Percentage based or Weight based
	
	Items = {
		
		[1] = {
			
			Name = "Item1",
			Chance = {50,100},
			AmountRange = {1,5} --The min and max amount that the item can drop
			
		},
		[2] = {

			Name = "Item2",
			Chance = {25,50},
			AmountRange = {1,5}

		},
		[3] = {

			Name = "Item3",
			Chance = {0,25},
			AmountRange = {1,5}

		},
		
	}
	
}

To do weight based tables, simply input “Weight” as the type, and input your weight as the chance

After you have done that and have required the module, create a new LootR table object like this:

local LootR = require(path.to.LootR)

local Table = LootR.new(LootTable)

Once you have done that, it’s as simple as calling it’s Roll function in order to roll for an item!

Item, Amount = Table:Roll() 
--Item being the string name of the rolled item, 
--and amount being the amount it has rolled

And it’s as simple as that!

Why use this over other loot table modules?

Honestly, this module probably doesn’t have nearly as many features as other loot table modules, so feel free to use one of those if you prefer. This mainly was just a fun coding challenge and I thought I’d share it!

I hope you enjoy it!

2 Likes

Never mind i fixed it idk why it was giving that error, great resource!

1 Like