Loadout: Guns, Bows, Blades and Spells Kit
README.md
audio
The weapons kit's sound cues: every gun, bow, blade, spell and toy weapon in the kit has a named cue (rifle_shot, bow_draw, hammer_smash, water_splash, …) that the kit's weapons, and any game using the kit, play with one call.
local Audio = require("weaponsKit.audio")
Audio.play("rifle_shot") -- the local player's own shot, flat
Audio.play("explosion_small", hitPos) -- 3D, at a position or an entity
Audio.play("impact_metal", target, { volume = 0.7, pitch = 1.1 })
local flame = Audio.loop("flame_loop", muzzleEntity) -- follows the entity
flame:stop()
Audio.define("rifle_shot", { asset.resolve("myGame.sounds.myRifle", "soundClip") })
Audio.cues(),Audio.has(cue),Audio.soundOf(cue)list and look up cues.Audio.play(cue, at?, { volume?, pitch? })returns true when a take started; an unknown cue warns once and returns false, never raises.Audio.loop(cue, at?, opts?)returns a handle with:stop(),:setPosition(pos),:setVolume(v)and:isPlaying().Audio.define(cue, clips)adds or replaces a cue with your own soundClip refs, identity strings or soundstage clip names.
Plays through soundstage (soundstage.sfx): each cue is a soundstage sound, either one of its built-in banks (weapons.pistol, impacts.metal, magic.lightning, …) or one of the kit's own generated clips in sounds/, registered as the weaponsKit bank. So every cue gets soundstage's random takes, pitch and volume jitter, cooldowns and the sfx mix group and volume slider. Loops are engine Audio voices on the same sfx channel and mix gain, since soundstage has no positional effect loop.
Sound plays only on the peer that calls it; it does no networking (use soundstage.sfx's broadcast for that). Like soundstage, it is silent in edit mode: play resolves the take and loop returns a handle that plays nothing.