0Pricing
Lua Academy · Lesson

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

  1. Event Systems in Lua
  2. Component-Based Scripting
  3. AI Behavior with State Machines
  4. Data-Driven Config and Hot-Reload
← Back to Lua Academy