Skip to main content

Throttle

Wraps a Types.Sense so it ticks every interval seconds instead of every agent tick. The first tick runs at once. Exposed as VluxyAI.Senses.Throttle.

:AddSense(VluxyAI.Senses.Throttle.new(VluxyAI.Senses.Sight.new({ Range = 40 }), 0.3))

The wrapped sense's blackboard keys keep their last values between runs, so a memory such as SeenPosition still ages by the wrapped sense's own clock.

Functions​

new​

Throttle.new(
sense: Sense,--

The sense to slow down.

interval: number--

Seconds between its ticks. Must be above 0.

) → Throttle

Errors

TypeDescription
string`sense` has no `Tick`, or `interval` is not above `0`.

Tick​

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

Adds deltaTime to this agent's clock and ticks the wrapped sense with the time gathered once it reaches the interval.

Destroy​

Throttle.Destroy(
self: Throttle,
agent: Agent?
) → ()

Forgets the agent's clock (or all of them) and forwards to the wrapped sense's Destroy.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "",
            "params": [
                {
                    "name": "sense",
                    "desc": "The sense to slow down.",
                    "lua_type": "Sense"
                },
                {
                    "name": "interval",
                    "desc": "Seconds between its ticks. Must be above `0`.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Throttle"
                }
            ],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "string",
                    "desc": "`sense` has no `Tick`, or `interval` is not above `0`."
                }
            ],
            "source": {
                "line": 48,
                "path": "lib/Senses/Throttle.luau"
            }
        },
        {
            "name": "Tick",
            "desc": "Adds `deltaTime` to this agent's clock and ticks the wrapped sense with the time gathered\nonce it reaches the interval.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Throttle"
                },
                {
                    "name": "agent",
                    "desc": "",
                    "lua_type": "Agent"
                },
                {
                    "name": "deltaTime",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 73,
                "path": "lib/Senses/Throttle.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Forgets the agent's clock (or all of them) and forwards to the wrapped sense's `Destroy`.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Throttle"
                },
                {
                    "name": "agent",
                    "desc": "",
                    "lua_type": "Agent?"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 98,
                "path": "lib/Senses/Throttle.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Throttle",
    "desc": "Wraps a [Types.Sense] so it ticks every `interval` seconds instead of every agent tick. The\nfirst tick runs at once. Exposed as `VluxyAI.Senses.Throttle`.\n\n```lua\n:AddSense(VluxyAI.Senses.Throttle.new(VluxyAI.Senses.Sight.new({ Range = 40 }), 0.3))\n```\n\nThe wrapped sense's blackboard keys keep their last values between runs, so a memory such as\n`SeenPosition` still ages by the wrapped sense's own clock.",
    "source": {
        "line": 40,
        "path": "lib/Senses/Throttle.luau"
    }
}