How to use IDs for data storage

Ill attempt to put this into practice tommorow and see how it goes. If you have any additional tips please share!

Could you tell me a little bit more on how exactly I should generate, assign, store, and load GUIDs specifically? I’ve never worked with HTTP service so I’m trying to fully grasp it first.

The codes are just something random that I made up. As for the enumerations, they are an organized way to represent fixed values (usually numerical). Think of them as constants, but related constants are grouped together. If you know anything about C…


enum itemQuality {
	Poor,
	Common,
	Uncommon,
	Rare,
	Epic,
	Legendary,
	Artifact,
	Moderator,
	Developer,
	Variable,
}

Once again, this is how you do it in the C programming language. In the case of C, it’s basically a list of values starting at 0.

To use custom enums in LUA using the definition method that I showed you, you would just assign or compare them like any table value. eg…

if variable == enums.ItemQuality.Variable then
	-- Do something
end

They are numbers and you can assign any numbers you want.

As for your other follow up question,

I personally wouldn’t use GUIDs for something like this because the storage footprint for a GUID is actually larger than a simple integer. Furthermore, I would just store the override stats of the specific item on a per player basis. Your code can use the information from the override data to link into the main item database to get everything else. In any case, you can implement your system any way that you wish. I opt for simplicity because GUIDs are usually only needed if you plan on having more that 231 (that’s 2,147,483,647) items in your game, which won’t be happening unless you’re employing an army of people making that content.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.