Voice
Random voice lines by state. Make one per agent and add it as a sense:
:AddSense(VluxyAI.Voice.new({
Lines = {
Patrol = { 9113636490, 9113636491 }, -- low groans while it wanders
Hunt = { 105926319962443 }, -- a growl now and then while it chases
["*"] = { 9113636681 }, -- anything else
},
Interval = { 5, 12 },
}))
A line never repeats twice in a row when the pool has another, never talks over the line
before it, and waits Interval between lines.
Functions
new
Types
interface VoiceOptions {Lines: {[string]: {number | string}}--
Line pools by state name: asset ids (or rbxasset:// strings). "*" is the pool for any state without its own; a state with neither is silent.
Interval: {number}?--
{ min, max } seconds between lines while in a state. Default { 6, 14 }.
OnEnter: (number | {[string]: number})?--
Chance, 0 to 1, of a line as the agent enters a state that has lines; or chances by state name, "*" for the rest (a state missing from the table gets 0.5). Default 0.5.
Volume: number?--
Default 0.8.
PitchVariation: number?--
Random spread of PlaybackSpeed around 1, so a repeated line does not sound stamped. Default 0.08.
RollOffMin: number?--
Studs heard at full volume. Default 8.
RollOffMax: number?--
Studs until silent. Default 80.
Emit: string?--
Announced with Agent:Emit as each line plays, { Line, State } as the payload, for subtitles. "" announces nothing. Default "Voice".
Play: ((line: number | string) → number?)?--
Plays a line your way instead (on the client, through your sound system) and returns its length in seconds. Default: a Sound under the rig's root, on the server.
}Errors
| Type | Description |
|---|---|
| "unknown option" | |
| "Lines needs at least one pool" | |
| "Interval must be { min, max } with 0 <= min <= max" |
Pick
Voice.Pick() → (number | string)?--
A random line from pool, never last when there is another, nil for an empty pool.
Pure.
NextDelay
Voice.NextDelay(interval: {number},--
{ min, max }.
random: Random) → number--
Seconds until the next line.
Pure.
Tick
Checks the agent's state: on entering one with lines it may speak at once (OnEnter), and
while in it speaks every Interval, never over its own last line.
Destroy
Removes the rig's voice Sound.