Navigation
Navigation agents: destinations, patrol points, follow targets and behaviour scripts.
Namespace: caffeine.navigation
setDestination#
Lua: caffeine.navigation.setDestination
setDestination(entity, x, y, z) -> boolean
Sets the agent's destination in world space.
| Parameters | Type | Description |
|---|---|---|
entity | number | Entity id. |
x | number | World X. |
y | number | World Y. |
z | number | World Z. |
Returns: boolean. true on success.
Example
caffeine.navigation.setDestination(npc, 10, 0, 5)
setMode#
Lua: caffeine.navigation.setMode
setMode(entity, mode) -> boolean
Sets the agent's navigation mode.
| Parameters | Type | Description |
|---|---|---|
entity | number | Entity id. |
mode | string | "patrol", "follow" or "scripted"; any other value means idle. |
Returns: boolean. true on success.
Example
caffeine.navigation.setMode(npc, 'patrol')
addPatrolPoint#
Lua: caffeine.navigation.addPatrolPoint
addPatrolPoint(entity, x, y, z) -> boolean
Appends a point to the agent's patrol route.
| Parameters | Type | Description |
|---|---|---|
entity | number | Entity id. |
x | number | World X. |
y | number | World Y. |
z | number | World Z. |
Returns: boolean. true on success.
Example
caffeine.navigation.addPatrolPoint(npc, 0, 0, 0)
setFollowTarget#
Lua: caffeine.navigation.setFollowTarget
setFollowTarget(entity, targetId) -> boolean
Sets the entity the agent follows.
| Parameters | Type | Description |
|---|---|---|
entity | number | Entity id. |
targetId | number | Entity id to follow. |
Returns: boolean. true on success.
Example
caffeine.navigation.setFollowTarget(npc, player)
setBehaviorScript#
Lua: caffeine.navigation.setBehaviorScript
setBehaviorScript(entity, path) -> boolean
Sets the script that drives the agent in scripted mode.
| Parameters | Type | Description |
|---|---|---|
entity | number | Entity id. |
path | string | Behaviour script path. |
Returns: boolean. true on success.
Example
caffeine.navigation.setBehaviorScript(npc, 'scripts/ai.lua')