AI Behavior with State Machines
Implement FSM-based enemy AI logic entirely in Lua scripts.
What Is a Finite State Machine?
A Finite State Machine (FSM) defines behavior as a set of states with transitions between them triggered by conditions or events.
FSM Table Structure
Represent an FSM as a table with a current state, a states table, and optional enter/exit/update callbacks per state.
local function newFSM(initialState)
return {
current = initialState,
states = {},
}
endAll lessons in this course
- Event Systems in Lua
- Component-Based Scripting
- AI Behavior with State Machines
- Data-Driven Config and Hot-Reload