Making enums/lists to be used across a game

I’m working on a game with my team and we’re working on an inventory system. I would like to use enums of rarities, items, obtainability percantages in crates, etc which I can access in multiple places. Is this possible?

local rarities =  {
	STARTER=0,
	COMMON=1,
	UNCOMMON=2,
	RARE=3,
	EPIC=4,
	LEGENDARY=5,
	ULTRA=6
}

I would be using these rarities and many other lists across the game. I’m somewhat new to lua, so I’m not completely sure how everything works (especially in game development). I’m wondering if I’d be able to do something similar to how Roblox has a big list of enums that you can use accross the game, or if there’s another way to share lists across certain parts of my game.

If you could help that would be great! :smile:

You can upload it as a module then require it in your games.

1 Like

Put that into a ModuleScript.

return {
	STARTER=0,
	COMMON=1,
	UNCOMMON=2,
	RARE=3,
	EPIC=4,
	LEGENDARY=5,
	ULTRA=6
}

Then require that ModuleScript from anywhere you need it.

2 Likes

Thanks!


1 Like