Garry's Mod Wiki

Revision Difference

Global.Sound#552341

<function name="Sound" parent="Global" type="libraryfunc"> <description> Runs <page>util.PrecacheSound</page> and returns the string. <bug><page>util.PrecacheSound</page> does nothing and therefore so does this function.</bug> </description> <realm>Shared and Menu</realm> <file line="123-L129">lua/includes/util.lua</file> <file line="127-L130">lua/includes/util.lua</file> <args> <arg name="soundPath" type="string">The soundpath to precache.</arg> </args> <rets> <ret name="" type="string">The string passed as the first argument.</ret> </rets> </function> <example> <description>From [entities/sent_ball.lua](https://github.com/Facepunch/garrysmod/blob/c4a74bebe3113b01aee85501c297530fb8fdfa81/garrysmod/lua/entities/sent_ball.lua#L98-L121).</description> <code> local BounceSound = Sound( "garrysmod/balloon_pop_cute.wav" ) function ENT:PhysicsCollide( data, physobj ) -- Play sound on bounce if ( data.Speed > 60 && data.DeltaTime > 0.2 ) then local pitch = 32 + 128 - math.Clamp( self:GetBallSize(), self.MinSize, self.MaxSize ) sound.Play( BounceSound, self:GetPos(), 75, math.random( pitch - 10, pitch + 10 ), math.Clamp( data.Speed / 150, 0, 1 ) ) end end </code> </example>