Skip to content

Commit 0cee06d

Browse files
committed
Minor fixes
- Example errors - Formatting lua code - Typos - playSFX3D syntax
1 parent f8b265d commit 0cee06d

File tree

79 files changed

+284
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+284
-258
lines changed

functions/Audio/examples/getSoundBufferLength-1.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ local ARTIST_POSITION = BOX_POSITION + Vector2(8, 32)
77

88
local sound
99

10-
addCommandHandler("playsound", function ()
10+
addCommandHandler("playsound", function()
1111
if isElement(sound) then
1212
destroyElement(sound)
1313
end
1414
sound = playSound("https://example.com/song.mp3")
1515
end)
1616

17-
addCommandHandler("stopsound", function ()
17+
addCommandHandler("stopsound", function()
1818
if isElement(sound) then
1919
destroyElement(sound)
2020
end
2121
end)
2222

23-
addEventHandler("onClientRender", root, function ()
23+
addEventHandler("onClientRender", root, function()
2424
if isElement(sound) then
2525
local soundLength = getSoundLength(sound)
2626
local soundPosition = getSoundPosition(sound)

functions/Audio/examples/getSoundBufferLength_OOP-1.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ local ARTIST_POSITION = BOX_POSITION + Vector2(8, 32)
77

88
local sound
99

10-
addCommandHandler("playsound", function ()
10+
addCommandHandler("playsound", function()
1111
if isElement(sound) then
1212
sound:destroy()
1313
end
1414
sound = Sound("https://example.com/song.mp3")
1515
end)
1616

17-
addCommandHandler("stopsound", function ()
17+
addCommandHandler("stopsound", function()
1818
if isElement(sound) then
1919
sound:destroy()
2020
end
2121
end)
2222

23-
addEventHandler("onClientRender", root, function ()
23+
addEventHandler("onClientRender", root, function()
2424
if isElement(sound) then
2525
local soundLength = sound.length
2626
local soundPosition = sound.playbackPosition
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
local sound = playSound ("music.mp3")
2-
setSoundEffectEnabled (sound, "echo", true)
1+
local sound = playSound("music.mp3")
2+
setSoundEffectEnabled(sound, "echo", true)
33

4-
local echoParams = getSoundEffectParameters (sound, "echo")
5-
print (echoParams.feedback) -- 50
6-
iprint (echoParams)
4+
local echoParams = getSoundEffectParameters(sound, "echo")
5+
print(echoParams.feedback) -- 50
6+
iprint(echoParams)
77
--[[
88
{
99
feedback = 50,
@@ -12,4 +12,4 @@ iprint (echoParams)
1212
rightDelay = 500,
1313
wetDryMix = 50
1414
}
15-
]]
15+
]]
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
local sound = Sound ("music.mp3")
1+
local sound = Sound("music.mp3")
22
sound:setEffectEnabled("echo", true)
33

44
local echoParams = sound:getEffectParameters("echo")
5-
print (echoParams.feedback) -- 50
6-
iprint (echoParams)
5+
print(echoParams.feedback) -- 50
6+
iprint(echoParams)
77
--[[
88
{
99
feedback = 50,
@@ -12,4 +12,4 @@ iprint (echoParams)
1212
rightDelay = 500,
1313
wetDryMix = 50
1414
}
15-
]]
15+
]]
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
function switchEffects(sound)
2-
for _,v in ipairs(getSoundEffects(sound)) do -- Go through the whole list of sound effects for the sound
3-
if v == "gargle" then -- If the sound effect is 'gargle', proceed
4-
setSoundEffectEnabled(sound, "gargle", false) -- Disable the 'gargle' -effect
5-
break
6-
end
7-
end
8-
end
2+
for _, v in ipairs(getSoundEffects(sound)) do -- Go through the whole list of sound effects for the sound
3+
if v == "gargle" then -- If the sound effect is 'gargle', proceed
4+
setSoundEffectEnabled(sound, "gargle", false) -- Disable the 'gargle' -effect
5+
break
6+
end
7+
end
8+
end
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
function switchEffects(sound)
2-
for _,v in ipairs(sound:getEffects()) do -- Go through the whole list of sound effects for the sound
3-
if v == "gargle" then -- If the sound effect is 'gargle', proceed
4-
sound:setEffectEnabled("gargle", false) -- Disable the 'gargle' -effect
5-
break
6-
end
7-
end
8-
end
2+
for _, v in ipairs(sound:getEffects()) do -- Go through the whole list of sound effects for the sound
3+
if v == "gargle" then -- If the sound effect is 'gargle', proceed
4+
sound:setEffectEnabled("gargle", false) -- Disable the 'gargle' -effect
5+
break
6+
end
7+
end
8+
end
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
local soundHandler = playSound ( "sound.wav" )
1+
local soundHandler = playSound("sound.wav")
22

3-
function onSoundPlayRender ( )
4-
if ( soundHandler ) then
5-
local soundFFT = getSoundFFTData ( soundHandler, 2048, 256 )
6-
if ( soundFFT ) then
3+
function onSoundPlayRender()
4+
if (soundHandler) then
5+
local soundFFT = getSoundFFTData(soundHandler, 2048, 256)
6+
if (soundFFT) then
77
for i = 0, 255 do -- Data starts from index 0
8-
dxDrawRectangle ( i, 0, 1, math.sqrt ( soundFFT[i] ) * 256 )
8+
dxDrawRectangle(i, 0, 1, math.sqrt(soundFFT[i]) * 256)
99
end
1010
end
1111
end
1212
end
13-
addEventHandler ( "onClientRender", getRootElement(), onSoundPlayRender )
13+
addEventHandler("onClientRender", getRootElement(), onSoundPlayRender)
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
local soundHandler = Sound ( "sound.wav" )
1+
local soundHandler = Sound("sound.wav")
22

3-
function onSoundPlayRender ( )
4-
if ( soundHandler ) then
5-
local soundFFT = soundHandler:getFFTData( 2048, 256 )
6-
if ( soundFFT ) then
3+
function onSoundPlayRender()
4+
if (soundHandler) then
5+
local soundFFT = soundHandler:getFFTData(2048, 256)
6+
if (soundFFT) then
77
for i = 0, 255 do -- Data starts from index 0
8-
dxDrawRectangle ( i, 0, 1, math.sqrt ( soundFFT[i] ) * 256 )
8+
dxDrawRectangle(i, 0, 1, math.sqrt(soundFFT[i]) * 256)
99
end
1010
end
1111
end
1212
end
13-
addEventHandler ( "onClientRender", getRootElement(), onSoundPlayRender )
13+
addEventHandler("onClientRender", getRootElement(), onSoundPlayRender)
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
local soundHandler = playSound ( "sound.wav" )
1+
local soundHandler = playSound("sound.wav")
22

3-
function onSoundPlayRender ( )
4-
if ( soundHandler ) then
5-
local leftData, rightData = getSoundLevelData ( soundHandler )
6-
if ( leftData ) then
7-
dxDrawRectangle ( 0, 0, 64, leftData / 32768 * 256, tocolor ( 255, 0, 0 ) )
8-
dxDrawRectangle ( 64, 0, 64, rightData / 32768 * 256, tocolor ( 0, 0, 255 ) )
3+
function onSoundPlayRender()
4+
if (soundHandler) then
5+
local leftData, rightData = getSoundLevelData(soundHandler)
6+
if (leftData) then
7+
dxDrawRectangle(0, 0, 64, leftData / 32768 * 256, tocolor(255, 0, 0))
8+
dxDrawRectangle(64, 0, 64, rightData / 32768 * 256, tocolor(0, 0, 255))
99
end
1010
end
1111
end
12-
addEventHandler ( "onClientRender", root, onSoundPlayRender )
12+
addEventHandler("onClientRender", root, onSoundPlayRender)
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
local soundHandler = Sound ( "sound.wav" )
1+
local soundHandler = Sound("sound.wav")
22

3-
function onSoundPlayRender ( )
4-
if ( soundHandler ) then
3+
function onSoundPlayRender()
4+
if (soundHandler) then
55
local leftData, rightData = soundHandler:getLevelData()
6-
if ( leftData ) then
7-
dxDrawRectangle ( 0, 0, 64, leftData / 32768 * 256, tocolor ( 255, 0, 0 ) )
8-
dxDrawRectangle ( 64, 0, 64, rightData / 32768 * 256, tocolor ( 0, 0, 255 ) )
6+
if (leftData) then
7+
dxDrawRectangle(0, 0, 64, leftData / 32768 * 256, tocolor(255, 0, 0))
8+
dxDrawRectangle(64, 0, 64, rightData / 32768 * 256, tocolor(0, 0, 255))
99
end
1010
end
1111
end
12-
addEventHandler ( "onClientRender", root, onSoundPlayRender )
12+
addEventHandler("onClientRender", root, onSoundPlayRender)

0 commit comments

Comments
 (0)