Revision Difference
Global.Sound#528213
<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>⤶
<bug><page>util.PrecacheSound</page> does nothing and therefore so does this function. This will be fixed in the next update.</bug>⤶
</description>
<realm>Shared and Menu</realm>
<file line="123-L126">lua/includes/util.lua</file>
<file line="123-L129">lua/includes/util.lua</file>
<args>
<arg name="soundPath" type="string">The soundpath to precache</arg>⤶
<arg name="soundPath" type="string">The soundpath to precache.</arg>⤶
</args>
<rets>
<ret name="" type="string">The string passed as the first argument</ret>⤶
<ret name="" type="string">The string passed as the first argument.</ret>⤶
</rets>
</function>
<example>
<description>From entities/sent_ball.lua</description>⤶
<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
sound.Play( BounceSound, self:GetPos(), 75, math.random( 90, 120 ), math.Clamp( data.Speed / 150, 0, 1 ) )
...
⤶
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></example>