Component-Based Scripting
Design game entities as tables with behavior components in Lua.
What Is Component-Based Design?
Instead of deep class hierarchies, entities are composed of components — small, focused tables of data and behavior. An entity is just a collection of components.
Entity as a Table
An entity is a table with an id and a components sub-table. Components are added and removed at runtime.
local function newEntity(id)
return {id = id, components = {}}
end
local player = newEntity(1)All lessons in this course
- Event Systems in Lua
- Component-Based Scripting
- AI Behavior with State Machines
- Data-Driven Config and Hot-Reload