Skip to content

Instantly share code, notes, and snippets.

@moonexpr
Created October 28, 2016 16:49
Show Gist options
  • Select an option

  • Save moonexpr/02c2a9f3420e8b99c8b5039eb03371c3 to your computer and use it in GitHub Desktop.

Select an option

Save moonexpr/02c2a9f3420e8b99c8b5039eb03371c3 to your computer and use it in GitHub Desktop.
this code is very old and redundant. (It's one of the first things I made)
function PotatoVox( URL )
sndcontrol = nil
cooldown = false
pixelsneeded = surface.ScreenWidth() / 1024
samples = {}
hook.Remove( "HUDPaint", "MusicEQ" )
locations = {
{Vector(-3211.039795, -10046.700195, 65.158920), Vector(-3226.494629, -10536.666016, 59.577229), Angle(-43.311, 157.197, 0.000), Angle(-33.016, -165.159, 0.000)},
{Vector(6354.061035, -5234.571289, -77.086594), Vector(5978.968262, -5243.521973, -89.630676), Angle(-30.316, 160.359, 0.000), Angle(-26.455, 33.267, 0.000)},
{Vector(1947.136230, 14781.557617, -428.222534), Vector(2625.922852, 14807.732422, 729.223999), Angle(-22.325, 178.216, 0.000), Angle(89.000, -176.314, 0.000)},
{Vector(-10665.098633, 10551.826172, 213.756607), Vector(-11170.581055, 11069.789062, 212.695938), Angle(-11.350, -147.862, 0.000), Angle(-17.785, -119.870, 0.000)},
{Vector(-14262.611328, 4540.423340, 170.459030), Vector(-14010.274414, 4928.529785, 170.459030), Angle(-24.864, -5.611, 0.000), Angle(-30.655, -53.873, 0.000)},
{Vector(3410.123779, 2632.318359, -359.398499), Vector(3410.123779, 2632.318359, -359.398499), Angle(-35.196, 161.056, 0.000), Angle(-26.830, -143.925, 0.000)},
{Vector(2807.707520, 3468.301025, 231.155563), Vector(5257.276367, 3297.038818, 231.155563), Angle(35.268, 45.226, 0.000), Angle(37.198, 112.150, 0.000)},
{Vector(7896.243164, 9102.817383, 250.539673), Vector(6614.946289, 9155.335938, 250.539673), Angle(49.764, -144.125, 0.000), Angle(48.477, -49.209, 0.000)},
{Vector(1667.392822, -6161.309570, -107.931976), Vector(1809.369141, -6054.053711, -19.749496), Angle(8.884, -142.516, 0.000), Angle(25.615, -142.838, 0.000)},
{Vector(6917.084473, -4948.667969, 366.516632), Vector(5838.233887, -4953.037109, 367.182159), Angle(9.528, 137.084, 0.000), Angle(8.562, 48.281, 0.000)},
{Vector(14302.103516, -8368.808594, -598.903381), Vector(14311.263672, -8179.649414, -598.875977), Angle(-27.152, 148.369, 0.000), Angle(-30.316, -150.139, 0.000)},
{Vector(13263.067383, -15431.477539, 163.992447), Vector(13989.121094, -16168.909180, 161.046707), Angle(-30.369, 136.748, 0.000), Angle(-15.891, 136.426, 0.000)},
{Vector(3584.875244, 3609.361816, 151.643356), Vector(3395.245850, 3388.463135, 89.250916), Angle(35.589, -152.884, 0.000), Angle(28.421, -136.797, 0.000)},
{Vector(-1798.532349, 1517.057495, 214.471649), Vector(-509.886200, 542.322937, 64.747345), Angle(-21.968, -106.373, 0.000), Angle(-18.751, -157.853, 0.000)},
{Vector(-2313.331543, -12792.386719, -413.354462), Vector(-2313.398193, -11594.824219, -173.723999), Angle(-9.098, -89.359, 0.000), Angle(2.807, -90.646, 0.000)},
{Vector(-1438.392334, 3503.969482, 203.509048), Vector(-1445.736084, 3310.935547, 201.788971), Angle(-1.287, 155.972, 0.000), Angle(0.322, 112.536, 0.000)},
}
Convars = {
"stopsound",
"pp_colormod 1",
"pp_colormod_addr 0",
"pp_colormod_addg 0",
"pp_colormod_addb 0",
"pp_colormod_mulr 0",
"pp_colormod_mulg 0",
"pp_colormod_mulb 0",
"pp_colormod_brightness 0",
"pp_colormod_color 1",
"pp_colormod_contrast 1",
"pp_bloom 1",
"pp_bloom_passes 1",
"pp_bloom_darken 1",
"pp_bloom_multiply 1",
"pp_bloom_sizex 0",
"pp_bloom_sizey 20",
"pp_bloom_color 2",
"pp_bloom_color_r 255",
"pp_bloom_color_r 255",
"pp_bloom_color_r 255",
}
for k, v in pairs(Convars) do
LocalPlayer():ConCommand( v )
end
function ChatPrint(msg)
chat.AddText( Color( 48, 48, 48 ), "【 ", Color( 200, 0, 100 ), "DJ", Color( 255, 255, 255 ), " | ", Color( 50, 150, 255 ), "PotatoVox", Color( 48, 48, 48 ), " 】", Color( 255, 255, 255), " " .. msg )
end
function EPOEPrint(msg)
epoe.AddText( Color( 48, 48, 48 ), "【 ", Color( 200, 0, 100 ), "DJ", Color( 255, 255, 255 ), " | ", Color( 50, 150, 255 ), "PotatoVox", Color( 48, 48, 48 ), " 】", Color( 255, 255, 255), " " .. msg .. "\n")
end
function CamTick()
local location = table.Random(locations)
ChatPrint("Camera Position: " .. tostring(location[1]))
local runtime = 10
local timerset = CurTime() + runtime
hook.Add( "CalcView", "CamTick", function(ply, pos, angles, fov)
local now = timerset - CurTime()
local value = now / runtime
if now < .1 then
hook.Remove( "CalcView", "CamTick" )
else
local view = {}
view.origin = LerpVector(value, location[1], location[2])
view.angles = LerpAngle(value, location[3], location[4])
return view
end
end )
end
function HeadTick( freq )
local mod = false
local runtime = .5
local timerset = CurTime() + runtime
hook.Add( "CalcView", "HeadTick", function(ply, pos, angles, fov)
local now = timerset - CurTime()
local value = math.Round( now, 2 ) / runtime
if not mod then
mod = true
if tobool(math.random( 0, 1 )) then
modifier = freq * 20
else
modifier = 0 - (freq * 20)
end
end
if now < .1 then
hook.Remove( "CalcView", "HeadTick" )
else
local view = {}
view.fov = fov + 10 * value
--view.angles = angles + Angle( 0, 0, angles.z + modifier * value )
return view
end
end )
end
function EffectNuke()
local runtime = 3
local timerset = CurTime() + runtime
local ninja = tobool(math.random(0,1))
hook.Add( "Tick", "NukeEffect", function ()
local now = timerset - CurTime()
local value = math.Round( now, 2 ) / runtime
if now < .1 then
LocalPlayer():ConCommand( "pp_bloom_darken 1")
hook.Remove( "Tick", "NukeEffect" )
else
if ninja then
LocalPlayer():ConCommand( "pp_colormod_color " .. 5 - (value * 5) + 1)
end
LocalPlayer():ConCommand( "pp_bloom_darken " .. 1 - value)
LocalPlayer():ConCommand( "pp_bloom_multiply " .. value * 5)
LocalPlayer():ConCommand( "pp_bloom_color " .. value * 10)
LocalPlayer():ConCommand( "pp_bloom_sizex " .. 50 + value * 100)
end
end )
end
function EffectColour( k, v )
local multiplier = math.Round( v, 2 ) * 20
local runtime = .5
local timerset = CurTime() + runtime
hook.Add( "Tick", "Shader", function ()
local now = timerset - CurTime()
local value = math.Round( now, 2 ) / runtime
if now < .1 then
hook.Remove( "Tick", "Shader" )
else
if k > 20 then
LocalPlayer():ConCommand( "pp_colormod_mulr " .. value * 255)
LocalPlayer():ConCommand( "pp_colormod_addr " .. value * multiplier)
end
if k > 15 then
LocalPlayer():ConCommand( "pp_colormod_mulg " .. value * 255)
LocalPlayer():ConCommand( "pp_colormod_addg " .. value * multiplier)
end
if k >= 0 then
LocalPlayer():ConCommand( "pp_colormod_mulb " .. value * 255)
LocalPlayer():ConCommand( "pp_colormod_addb " .. value * multiplier)
end
end
end )
end
function EffectWhite( v )
local runtime = 1
local timerset = CurTime() + runtime
hook.Add( "Tick", "EffectColour", function ()
local now = timerset - CurTime()
local value = math.Round( now, 2 ) / runtime
if now < 0 then
hook.Remove( "Tick", "EffectColour" )
else
if value > .1 then
LocalPlayer():ConCommand( "pp_colormod_contrast " .. value * 10 * v )
else
LocalPlayer():ConCommand( "pp_colormod_contrast 1" )
end
end
end )
--CamTick()
--HeadTick( v )
end
function EffectBlack( v )
local runtime = 1 + v
local timerset = CurTime() + runtime
hook.Add( "Tick", "EffectBlack", function ()
local now = timerset - CurTime()
local value = now / runtime
if now < 0 then
hook.Remove( "Tick", "EffectBlack" )
LocalPlayer():ConCommand( "pp_colormod_brightness 0" )
else
LocalPlayer():ConCommand( "pp_colormod_brightness " .. 0 - (1 * value) )
end
end )
end
function Play( internal_url, data )
sound.PlayURL( internal_url, "mono", function (sndcontrol)
sndcontrol:Play()
timer.Destroy"PotatovoxFadeaway"
timer.Create( "PotatovoxFadeaway", math.Round(sndcontrol:GetLength()), 1, function()
local AddR = GetConVar( "pp_colormod_addr"):GetInt()
local AddG = GetConVar( "pp_colormod_addg"):GetInt()
local AddB = GetConVar( "pp_colormod_addb"):GetInt()
local MulR = GetConVar( "pp_colormod_mulr"):GetInt()
local MulG = GetConVar( "pp_colormod_mulg"):GetInt()
local MulB = GetConVar( "pp_colormod_mulb"):GetInt()
local runtime = 2
local timerset = CurTime() + runtime
hook.Add( "Tick", "ReturnColor", function ()
local now = timerset - CurTime()
local value = math.Round( now, 2 ) / runtime
if now <= 0 then
hook.Remove( "Tick", "ReturnColor" )
LocalPlayer():ConCommand( "pp_colormod 0" )
LocalPlayer():ConCommand( "pp_bloom 0" )
else
LocalPlayer():ConCommand( "pp_colormod_addr " .. value * AddR )
LocalPlayer():ConCommand( "pp_colormod_addg " .. value * AddG )
LocalPlayer():ConCommand( "pp_colormod_addb " .. value * AddB )
LocalPlayer():ConCommand( "pp_colormod_mulr " .. value * MulR )
LocalPlayer():ConCommand( "pp_colormod_mulg " .. value * MulG )
LocalPlayer():ConCommand( "pp_colormod_mulb " .. value * MulB )
end
end )
end)
hook.Add( "HUDPaint", "MusicEQ", function ()
--sndcontrol:SetPlaybackRate(1.5)
sndcontrol:FFT( samples, FFT_1024 )
sndcontrol:SetVolume(GetConVar("snd_musicvolume"):GetFloat())
spacer = 0
for k, v in pairs(samples) do
if math.Round( v, 2) > .9 then
EffectNuke()
elseif math.Round( v, 2) > .7 then
surface.SetDrawColor( Color( math.random(0, 255), math.random(0, 255), math.random(0, 255) ) )
EffectBlack( v )
elseif math.Round( v, 2) > .5 then
surface.SetDrawColor( Color( 0, 0, 255 ) )
EffectWhite( v )
elseif math.Round( v, 2) > .25 then
surface.SetDrawColor( Color( 0, 0, 100 ) )
EffectColour( k, v )
else
if spacer >= (sndcontrol:GetTime() / sndcontrol:GetLength()) * ScrW() then
surface.SetDrawColor( Color( 255, 0, 0 ) )
else
surface.SetDrawColor( Color( 200, 200, 200 ) )
end
end
local size = v * (ScrH() / 2)
surface.DrawRect( spacer, 0, 4, math.Clamp(size, 3, ScrH() / 1.5))
spacer = spacer + pixelsneeded + 2
end
end )
end )
if data then
chatimage(data["artwork_url"] and string.gsub(data["artwork_url"], "large.jpg", "t500x500.jpg") or [[http://www.diablogaming.org/data/avatars/l/0/2.jpg?1452571165]])
ChatPrint( string.format("<color=100,100,100>%s<color=255,255,255> ~ <color=200,200,0>%s (%s)",
data["title"],
data["user"]["username"],
data["genre"] and data["genre"] or "Unknown Genre"
) )
ChatPrint( "Music powered by http://soundcloud.com" )
else
ChatPrint( "Now Playing: " .. URL )
end
end
--[[if string.find(URL, "soundcloud.com") then
http.Fetch("http://api.soundcloud.com/resolve.json?url=" .. URL .. "&client_id=02gUJC0hH2ct1EGOcYXQIzRFU91c72Ea",
function( json )
timer.Simple(.5, function()
local tab = util.JSONToTable( json )
if string.find(tab["stream_url"], "secret_token") then
Play(tab["stream_url"] .. "&client_id=[GET YOUR OWN]", tab)
else
Play(tab["stream_url"] .. "?client_id=[GET YOUR OWN]", tab)
end
end )
end,
function( error )
chat.AddText("Error parsing the URL :( @DebugCode " .. error)
end)
else]]
Play( URL, nil )
--end
end
--PotatoVox("https://soundcloud.com/sigalamusic/sweetlovin")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment