Skip to main content

Stamina

A Types.Sense for tiring: drains while the agent moves faster than Threshold, recovers otherwise, and writes the meter under Key. A brain rests at 0 and hunts again once it has recovered, and a sprint has a length the player can learn.

:AddSense(VluxyAI.Senses.Stamina.new({ Threshold = 10, Drain = 0.07, Regen = 0.2 }))
-- in the brain
{ To = "Rest", When = VluxyAI.When.Below("Stamina", 0.01) },

Functions​

new​

Stamina.new(options: StaminaOptions?) → Stamina

Types

​

interface StaminaOptions {
Threshold: number?--

Studs per second above which the meter drains. Default 10.

Drain: number?--

Per second while above Threshold. 1 / Drain seconds empties a full meter. Default 0.1.

Regen: number?--

Per second otherwise. Default 0.2.

Key: string?--

The blackboard key written, 0 to 1. It starts at whatever the blackboard holds there, else 1. Default "Stamina".

Prefix: string?--

Prepended to the key. Default "".

}

Errors

TypeDescription
"unknown option"
"Drain and Regen must be zero or more"

Tick​

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

Measures the speed since the last tick and moves the meter.

Destroy​

Stamina.Destroy(self: Stamina) → ()

Nothing to release.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "",
            "params": [
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "StaminaOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Stamina"
                }
            ],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "\"unknown option\"",
                    "desc": ""
                },
                {
                    "lua_type": "\"Drain and Regen must be zero or more\"",
                    "desc": ""
                }
            ],
            "source": {
                "line": 83,
                "path": "lib/Senses/Stamina.luau"
            }
        },
        {
            "name": "Tick",
            "desc": "Measures the speed since the last tick and moves the meter.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Stamina"
                },
                {
                    "name": "agent",
                    "desc": "",
                    "lua_type": "Agent"
                },
                {
                    "name": "deltaTime",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 99,
                "path": "lib/Senses/Stamina.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Nothing to release.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "Stamina"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 124,
                "path": "lib/Senses/Stamina.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "StaminaOptions",
            "desc": "",
            "fields": [
                {
                    "name": "Threshold",
                    "lua_type": "number?",
                    "desc": "Studs per second above which the meter drains. Default `10`."
                },
                {
                    "name": "Drain",
                    "lua_type": "number?",
                    "desc": "Per second while above `Threshold`. `1 / Drain` seconds empties a full meter. Default `0.1`."
                },
                {
                    "name": "Regen",
                    "lua_type": "number?",
                    "desc": "Per second otherwise. Default `0.2`."
                },
                {
                    "name": "Key",
                    "lua_type": "string?",
                    "desc": "The blackboard key written, `0` to `1`. It starts at whatever the blackboard holds there, else `1`. Default `\"Stamina\"`."
                },
                {
                    "name": "Prefix",
                    "lua_type": "string?",
                    "desc": "Prepended to the key. Default `\"\"`."
                }
            ],
            "source": {
                "line": 36,
                "path": "lib/Senses/Stamina.luau"
            }
        }
    ],
    "name": "Stamina",
    "desc": "A [Types.Sense] for tiring: drains while the agent moves faster than `Threshold`, recovers\notherwise, and writes the meter under `Key`. A brain rests at `0` and hunts again once it has\nrecovered, and a sprint has a length the player can learn.\n\n```lua\n:AddSense(VluxyAI.Senses.Stamina.new({ Threshold = 10, Drain = 0.07, Regen = 0.2 }))\n-- in the brain\n{ To = \"Rest\", When = VluxyAI.When.Below(\"Stamina\", 0.01) },\n```",
    "source": {
        "line": 75,
        "path": "lib/Senses/Stamina.luau"
    }
}