Skip to main content

Doors

Doors agents open, over a Types.DoorDriver your game supplies. Doors.Step is the registration for [Builder:OnStep]:

:OnStep("Door", VluxyAI.Doors.Step())

With no driver it uses [Doors.Attributes]: opening a door sets its VLUXYAI_DOOR/Open attribute to true, and your door script swings it and sets it back to false when it closes. VLUXYAI_DOOR/Locked = true makes an agent refuse it and plan around it; VLUXYAI_DOOR/OpenTime is how many seconds the agent waits for the swing.

For doors that agents never collide with (put the doors and the rigs in collision groups that do not collide), let the agent walk through instead of stopping, open doors it walks up to on a direct line, and let the straight-line check look past them:

:UseDirect(VluxyAI.Pathfinders.Straight.new({
	Ignore = VluxyAI.Doors.IgnoreUnlocked(VluxyAI.Pathfinders.Straight.DefaultIgnore),
}))
:OnStep("Door", VluxyAI.Doors.Step(nil, { WalkThrough = true }))
:AddSense(VluxyAI.Doors.Opener())

Then the navmesh modifier alone decides what is passable: PassThrough on while the door is unlocked, off while it is locked.

Authoring a door for the navmesh: tag the door VLUXYAI_DOOR, give it a PathfindingModifier with PassThrough on and Label = "Door", and put an invisible, non-colliding part a few studs deep across the doorway with a modifier labelled "Door", so a waypoint always lands in the doorway. Navmesh moves the stop to the waypoint before the doorway.

Properties​

OPEN_ATTRIBUTE​

Doors.OPEN_ATTRIBUTE: "VLUXYAI_DOOR/Open"

The attribute Doors.Attributes sets to open a door and reads to see that it is open.

LOCKED_ATTRIBUTE​

Doors.LOCKED_ATTRIBUTE: "VLUXYAI_DOOR/Locked"

true on a door makes Doors.Attributes report it locked.

OPEN_TIME_ATTRIBUTE​

Doors.OPEN_TIME_ATTRIBUTE: "VLUXYAI_DOOR/OpenTime"

Seconds the door takes to open, read by Doors.Attributes.

Attributes​

Doors.Attributes: DoorDriver

The default driver. Open sets VLUXYAI_DOOR/Open to true; IsOpen reads it; IsLocked reads VLUXYAI_DOOR/Locked; OpenTime reads VLUXYAI_DOOR/OpenTime when it is a number. Your door script listens to VLUXYAI_DOOR/Open, and sets it itself when a player opens or closes the door so agents know.

Functions​

Step​

Doors.Step(
driver: DoorDriver?,--

How your doors open. Default Doors.Attributes.

) → StepRegistration--

For Builder:OnStep.

Types

​

interface DoorStepOptions {
Tag: string?--

CollectionService tag that finds the door for a navmesh step, which arrives without its Instance. Default "VLUXYAI_DOOR".

Radius: number?--

Studs from the step to look for the tagged door. Default 8.

OpenTime: number?--

Seconds to wait after opening, for a driver with no OpenTime of its own. Default 0.5.

CloseSeconds: number?--

Seconds a locked door is planned around before the agent tries it again. Default 10.

Emit: string?--

Sent with Agent:Emit as a door is opened, the door as the payload, so a client can play a reach. "" sends nothing. Default "Door".

WalkThrough: boolean?--

Open a closed door and keep walking instead of stopping at it, for doors that never collide with agents. Default false.

}

The registration for a door label. When the agent reaches the step:

  • an open door (or a step with no door found) is walked through without stopping;
  • a locked door is refused: the path fails and the pathfinder plans around that doorway for CloseSeconds;
  • a closed door is opened. By default the agent stops, Agent:Emits Emit, calls the driver's Open, waits OpenTime, and walks on. With WalkThrough it opens the door and keeps walking.

Errors

TypeDescription
"unknown option"A key that is not in `DoorStepOptions`.
"driver needs IsOpen and Open"

Opener​

Doors.Opener(options: DoorOpenerOptions?) → Sense

Types

​

interface DoorOpenerOptions {
Tag: string?--

CollectionService tag of the doors. Default "VLUXYAI_DOOR".

Radius: number?--

Studs from the agent within which a door ahead is opened. Default 6.

Facing: number?--

How squarely the agent must face the door to open it: the dot product of its look direction and the direction to the door, from -1 (any way) to 1 (dead ahead). Keeps an agent walking past a door in a side wall from opening it. Default 0.3.

Emit: string?--

Sent with Agent:Emit as a door is opened. "" sends nothing. Default "Door".

Driver: DoorDriver?--

Default Doors.Attributes.

Prefix: string?--

Prepended to the keys this sense writes. Default "".

}

A sense for doors the agent walks up to without a labelled step, such as on a direct walk. Each tick it finds the nearest tagged door within Radius that the agent is facing, writes it as NearDoor (and NearDoorDistance, math.huge when there is none), and opens it if it is closed and not locked. Meant for doors agents never collide with; add it with Builder:AddSense.

Errors

TypeDescription
"unknown option"A key that is not in `DoorOpenerOptions`.
"driver needs IsOpen and Open"

Tick​

Doors.Tick(
self: Opener,
agent: Agent,
deltaTime: number
) → ()

The Doors.Opener sense's tick: writes NearDoor and NearDoorDistance, and opens that door when it is closed and unlocked.

Destroy​

Doors.Destroy(self: Opener) → ()

Nothing to release.

IgnoreUnlocked​

Doors.IgnoreUnlocked(
base: (agent: Agent) → {Instance},--

The ignore list to extend, such as Straight.DefaultIgnore.

driver: DoorDriver?,--

Default Doors.Attributes.

tag: string?--

Default "VLUXYAI_DOOR".

) → (agent: Agent) → {Instance}--

An Ignore for Straight or Sight.

An ignore list that also passes through every tagged door the agent could open, so a direct walk treats an unlocked door as the open doorway it is to an agent that never collides with it. Locked doors still block.

Show raw api
{
    "functions": [
        {
            "name": "Step",
            "desc": "The registration for a door label. When the agent reaches the step:\n\n- an open door (or a step with no door found) is walked through without stopping;\n- a locked door is refused: the path fails and the pathfinder plans around that doorway for\n  `CloseSeconds`;\n- a closed door is opened. By default the agent stops, [Agent:Emit]s `Emit`, calls the\n  driver's `Open`, waits `OpenTime`, and walks on. With `WalkThrough` it opens the door and\n  keeps walking.",
            "params": [
                {
                    "name": "driver",
                    "desc": "How your doors open. Default [Doors.Attributes].",
                    "lua_type": "DoorDriver?"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "DoorStepOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "For [Builder:OnStep].",
                    "lua_type": "StepRegistration"
                }
            ],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "\"unknown option\"",
                    "desc": "A key that is not in `DoorStepOptions`."
                },
                {
                    "lua_type": "\"driver needs IsOpen and Open\"",
                    "desc": ""
                }
            ],
            "source": {
                "line": 261,
                "path": "lib/World/Doors.luau"
            }
        },
        {
            "name": "Opener",
            "desc": "A sense for doors the agent walks up to without a labelled step, such as on a direct walk.\nEach tick it finds the nearest tagged door within `Radius` that the agent is facing, writes\nit as `NearDoor` (and `NearDoorDistance`, `math.huge` when there is none), and opens it if it\nis closed and not locked. Meant for doors agents never collide with; add it with\n[Builder:AddSense].",
            "params": [
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "DoorOpenerOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Sense"
                }
            ],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "\"unknown option\"",
                    "desc": "A key that is not in `DoorOpenerOptions`."
                },
                {
                    "lua_type": "\"driver needs IsOpen and Open\"",
                    "desc": ""
                }
            ],
            "source": {
                "line": 347,
                "path": "lib/World/Doors.luau"
            }
        },
        {
            "name": "Tick",
            "desc": "The [Doors.Opener] sense's tick: writes `NearDoor` and `NearDoorDistance`, and opens that door\nwhen it is closed and unlocked.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Opener"
                },
                {
                    "name": "agent",
                    "desc": "",
                    "lua_type": "Agent"
                },
                {
                    "name": "deltaTime",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 368,
                "path": "lib/World/Doors.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Nothing to release.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Opener"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 411,
                "path": "lib/World/Doors.luau"
            }
        },
        {
            "name": "IgnoreUnlocked",
            "desc": "An ignore list that also passes through every tagged door the agent could open, so a direct\nwalk treats an unlocked door as the open doorway it is to an agent that never collides with\nit. Locked doors still block.",
            "params": [
                {
                    "name": "base",
                    "desc": "The ignore list to extend, such as [Straight.DefaultIgnore].",
                    "lua_type": "(agent: Agent) -> { Instance }"
                },
                {
                    "name": "driver",
                    "desc": "Default [Doors.Attributes].",
                    "lua_type": "DoorDriver?"
                },
                {
                    "name": "tag",
                    "desc": "Default `\"VLUXYAI_DOOR\"`.",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "An `Ignore` for [Straight] or [Sight].",
                    "lua_type": "(agent: Agent) -> { Instance }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 428,
                "path": "lib/World/Doors.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "OPEN_ATTRIBUTE",
            "desc": "The attribute [Doors.Attributes] sets to open a door and reads to see that it is open.",
            "lua_type": "\"VLUXYAI_DOOR/Open\"",
            "source": {
                "line": 154,
                "path": "lib/World/Doors.luau"
            }
        },
        {
            "name": "LOCKED_ATTRIBUTE",
            "desc": "`true` on a door makes [Doors.Attributes] report it locked.",
            "lua_type": "\"VLUXYAI_DOOR/Locked\"",
            "source": {
                "line": 162,
                "path": "lib/World/Doors.luau"
            }
        },
        {
            "name": "OPEN_TIME_ATTRIBUTE",
            "desc": "Seconds the door takes to open, read by [Doors.Attributes].",
            "lua_type": "\"VLUXYAI_DOOR/OpenTime\"",
            "source": {
                "line": 170,
                "path": "lib/World/Doors.luau"
            }
        },
        {
            "name": "Attributes",
            "desc": "The default driver. `Open` sets `VLUXYAI_DOOR/Open` to `true`; `IsOpen` reads it; `IsLocked` reads\n`VLUXYAI_DOOR/Locked`; `OpenTime` reads `VLUXYAI_DOOR/OpenTime` when it is a number. Your door script\nlistens to `VLUXYAI_DOOR/Open`, and sets it itself when a player opens or closes the door so agents\nknow.",
            "lua_type": "DoorDriver",
            "source": {
                "line": 181,
                "path": "lib/World/Doors.luau"
            }
        }
    ],
    "types": [
        {
            "name": "DoorStepOptions",
            "desc": "",
            "fields": [
                {
                    "name": "Tag",
                    "lua_type": "string?",
                    "desc": "`CollectionService` tag that finds the door for a navmesh step, which arrives without its `Instance`. Default `\"VLUXYAI_DOOR\"`."
                },
                {
                    "name": "Radius",
                    "lua_type": "number?",
                    "desc": "Studs from the step to look for the tagged door. Default `8`."
                },
                {
                    "name": "OpenTime",
                    "lua_type": "number?",
                    "desc": "Seconds to wait after opening, for a driver with no `OpenTime` of its own. Default `0.5`."
                },
                {
                    "name": "CloseSeconds",
                    "lua_type": "number?",
                    "desc": "Seconds a locked door is planned around before the agent tries it again. Default `10`."
                },
                {
                    "name": "Emit",
                    "lua_type": "string?",
                    "desc": "Sent with [Agent:Emit] as a door is opened, the door as the payload, so a client can play a reach. `\"\"` sends nothing. Default `\"Door\"`."
                },
                {
                    "name": "WalkThrough",
                    "lua_type": "boolean?",
                    "desc": "Open a closed door and keep walking instead of stopping at it, for doors that never collide with agents. Default `false`."
                }
            ],
            "source": {
                "line": 63,
                "path": "lib/World/Doors.luau"
            }
        },
        {
            "name": "DoorOpenerOptions",
            "desc": "",
            "fields": [
                {
                    "name": "Tag",
                    "lua_type": "string?",
                    "desc": "`CollectionService` tag of the doors. Default `\"VLUXYAI_DOOR\"`."
                },
                {
                    "name": "Radius",
                    "lua_type": "number?",
                    "desc": "Studs from the agent within which a door ahead is opened. Default `6`."
                },
                {
                    "name": "Facing",
                    "lua_type": "number?",
                    "desc": "How squarely the agent must face the door to open it: the dot product of its look direction and the direction to the door, from `-1` (any way) to `1` (dead ahead). Keeps an agent walking past a door in a side wall from opening it. Default `0.3`."
                },
                {
                    "name": "Emit",
                    "lua_type": "string?",
                    "desc": "Sent with [Agent:Emit] as a door is opened. `\"\"` sends nothing. Default `\"Door\"`."
                },
                {
                    "name": "Driver",
                    "lua_type": "DoorDriver?",
                    "desc": "Default [Doors.Attributes]."
                },
                {
                    "name": "Prefix",
                    "lua_type": "string?",
                    "desc": "Prepended to the keys this sense writes. Default `\"\"`."
                }
            ],
            "source": {
                "line": 92,
                "path": "lib/World/Doors.luau"
            }
        }
    ],
    "name": "Doors",
    "desc": "Doors agents open, over a [Types.DoorDriver] your game supplies. [Doors.Step] is the\nregistration for [Builder:OnStep]:\n\n```lua\n:OnStep(\"Door\", VluxyAI.Doors.Step())\n```\n\nWith no driver it uses [Doors.Attributes]: opening a door sets its `VLUXYAI_DOOR/Open` attribute to\n`true`, and your door script swings it and sets it back to `false` when it closes.\n`VLUXYAI_DOOR/Locked = true` makes an agent refuse it and plan around it; `VLUXYAI_DOOR/OpenTime` is\nhow many seconds the agent waits for the swing.\n\nFor doors that agents never collide with (put the doors and the rigs in collision groups that\ndo not collide), let the agent walk through instead of stopping, open doors it walks up to on\na direct line, and let the straight-line check look past them:\n\n```lua\n:UseDirect(VluxyAI.Pathfinders.Straight.new({\n\tIgnore = VluxyAI.Doors.IgnoreUnlocked(VluxyAI.Pathfinders.Straight.DefaultIgnore),\n}))\n:OnStep(\"Door\", VluxyAI.Doors.Step(nil, { WalkThrough = true }))\n:AddSense(VluxyAI.Doors.Opener())\n```\n\nThen the navmesh modifier alone decides what is passable: `PassThrough` on while the door is\nunlocked, off while it is locked.\n\nAuthoring a door for the navmesh: tag the door `VLUXYAI_DOOR`, give it a `PathfindingModifier` with\n`PassThrough` on and `Label = \"Door\"`, and put an invisible, non-colliding part a few studs deep\nacross the doorway with a modifier labelled `\"Door\"`, so a waypoint always lands in the doorway.\n[Navmesh] moves the stop to the waypoint before the doorway.",
    "source": {
        "line": 147,
        "path": "lib/World/Doors.luau"
    }
}