Unit = { class = "Unit", faction = 0, troops = {}, is_selected = false, portrait = nil, stat = { health = nil, speed = nil } } function Unit:newUnit(name,faction,portrait,stat_table) o = { -- ids name = name, faction = faction, portrait = love.graphics.newImage(portrait), -- stats stat = { health = stat_table.health, speed = stat_table.speed } } setmetatable(o, self) self.__index = self return o end