ReloadPlugin("LuaAudio") local intro = tonumber(GetVariable("intro") or "") if not intro or ppi.isPlaying(intro) == 0 then temp = ppi.play(dir.."sounds/ogg/music/IntroMusic/DefaultIntro.ogg", 1, 0, 40) SetVariable("intro", temp) end temp=GetVariable("intro") ppi.stop(temp) temp=GetVariable("intro") ppi.stop(temp) action="%1" path="%2" volume="%3" pitch="%4" pan="%5" id="%6" volume=tonumber(volume) if (path == "na") then else sound_path = dir .. "sounds/ogg/" .. path .. ".ogg" directory_path = sound_path:match("(.*/)") if directory_path then test_file = io.open(directory_path .. "tester.txt", "w") if test_file then test_file:close() os.remove(directory_path .. "checker.txt") -- Clean up else os.execute('mkdir "' .. directory_path .. '" 2>nul') end end file = io.open(sound_path, "r") if file then file:close() else local encoded_path = url_encode(path) local download_url = "http://nathantech.net:3000/CosmicRage/CosmicRageSounds/raw/branch/main/ogg/" .. encoded_path .. ".ogg" body = {} result, status_code, headers, status = socket.http.request{ url = download_url, sink = ltn12.sink.table(body) } if result and status_code == 200 then save_file = io.open(sound_path, "wb") if save_file then save_file:write(table.concat(body)) save_file:close() end else Note("Download of "..path.." failed with status code: " .. tostring(status_code)) end end end if (pitch == "na") then pitch = -10000 else pitch = tonumber(pitch) pitch = (pitch - 44100) / 98 end if (pan == "na") then pan = -10000 else pan = tonumber(pan) end if (action == "play") then temp = ppi.play(dir.."sounds/ogg/"..path..".ogg", 0, pan, volume) if (pitch > -10000) then ppi.setPitch(pitch, temp) end if (pan > -10000) then ppi.setPan(pan, temp) end end if (action=="playrec") then temp=ppi.play(dir.."sounds/ogg/"..path..".ogg", 0, pan, volume) SetVariable(id, temp) if(pitch>-10000) then ppi.setPitch(pitch,temp) end if(pan>-10000) then ppi.setPan(pan,temp) end end if (action=="loop") then temp=ppi.play(dir.."sounds/ogg/"..path..".ogg", 1, pan, volume) SetVariable(id, temp) if(pitch>-10000) then ppi.setPitch(pitch,temp) end if(pan>-10000) then ppi.setPan(pan,temp) end end if (action=="adjustsound") then temp=GetVariable (id) if(volume>-1) then ppi.setVol(volume,temp) end if(pitch>-10000) then ppi.setPitch(pitch,temp) end if(pan>-10000) then ppi.setPan(pan,temp) end end if (action=="stop") then temp=GetVariable(id) ppi.stop(temp) end