So I have started working on a survival game, and decided to take an OOP based approach to the game. I am semi-experienced, but I am definitely not the best. SO I was wondering, before getting too far into this project, if this is a good way to create a player class?
local players = {}
players.__index = players
function players.new(player)
return setmetatable({
backpack = {},
hotbar = {},
health = 100,
maxHealth = 100,
}, players)
end
return players
Is it wise to have the backpack and hotbar as objects instead of folders in the player? This means that I would have to send a remote event every time a player wants to view their inventory, or something in the inventory changes. Should I also create an inventory folder in the player where values are inserted, so that the client can better view them?
Or should I have a seperate module for the inventory system, so things aren’t as cluttered in the player class?
Im not sure if this is the best approach, so any feedback is appreciated!