Grid-based Inventory

I am about to start work on a grid-based inventory for a gamemode I’m creating. I am fairly new to Lua but am learning quickly thanks to the Wiki. I want to have some sort of template system, where containers of similar size all draw their shape from this template, but all have their own contents.
I planned on naming each individual square using coordinates, where X is a letter and Y is a number, so container spaces would be represented like A1, B4 and so on in the code. Items would have many different shapes and sizes and players must manage their space wisely, like a puzzle.

Any ideas on how to do this? My way would be the long, hard, and inefficient way. Has it already been done?

When doing this, try to keep as little information on the server as possible, while still keeping it secure.

So:

  • Keep the items on the server and send them to the client when needed.
  • Keep the individual item grid positions on the client(in a text file when saving for example).
  • Make sure that when you load an inventory from the client-side file, you verify no items are on top of eachother(otherwise it’d be quite easy to cheat).

Couldn’t we just keep all of that server side? I mean, the storing of inventory contents. Since every container is an actual object that can be placed in the world at any time.

Yes, that is what I meant, but the grid positions should remain with the client. If it’s an actual inventory. You could fit the items in an individual container with your own algorithm, to make it fit in the container properly.

In these cases, all you’d have to network are the items in the container/player inventory.

What do we actually mean when we say client- or server-side when it comes to this? Like I said, I’m new. I don’t fully understand even what I’m talking about. I bet you’d laugh (if you are so inclined) if you saw the code I have written so far (for other things, haven’t started containers yet).

If you are new to lua my advice would be not to start with an inventory, as what you are trying to do would take quite a bit of lua knowledge to complete.