Caffeine

Navigation

Reference World Last updated: Lua 5 · Dryad 0

Navigation agents: destinations, patrol points, follow targets and behaviour scripts.

All namespaces

Namespace: caffeine.navigation

setDestination#

Lua: caffeine.navigation.setDestination

text
setDestination(entity, x, y, z) -> boolean

Sets the agent's destination in world space.

ParametersTypeDescription
entitynumberEntity id.
xnumberWorld X.
ynumberWorld Y.
znumberWorld Z.

Returns: boolean. true on success.

Example

lua
caffeine.navigation.setDestination(npc, 10, 0, 5)

setMode#

Lua: caffeine.navigation.setMode

text
setMode(entity, mode) -> boolean

Sets the agent's navigation mode.

ParametersTypeDescription
entitynumberEntity id.
modestring"patrol", "follow" or "scripted"; any other value means idle.

Returns: boolean. true on success.

Example

lua
caffeine.navigation.setMode(npc, 'patrol')

addPatrolPoint#

Lua: caffeine.navigation.addPatrolPoint

text
addPatrolPoint(entity, x, y, z) -> boolean

Appends a point to the agent's patrol route.

ParametersTypeDescription
entitynumberEntity id.
xnumberWorld X.
ynumberWorld Y.
znumberWorld Z.

Returns: boolean. true on success.

Example

lua
caffeine.navigation.addPatrolPoint(npc, 0, 0, 0)

setFollowTarget#

Lua: caffeine.navigation.setFollowTarget

text
setFollowTarget(entity, targetId) -> boolean

Sets the entity the agent follows.

ParametersTypeDescription
entitynumberEntity id.
targetIdnumberEntity id to follow.

Returns: boolean. true on success.

Example

lua
caffeine.navigation.setFollowTarget(npc, player)

setBehaviorScript#

Lua: caffeine.navigation.setBehaviorScript

text
setBehaviorScript(entity, path) -> boolean

Sets the script that drives the agent in scripted mode.

ParametersTypeDescription
entitynumberEntity id.
pathstringBehaviour script path.

Returns: boolean. true on success.

Example

lua
caffeine.navigation.setBehaviorScript(npc, 'scripts/ai.lua')