diff options
author | UbitUmarov | 2018-04-09 00:15:45 +0100 |
---|---|---|
committer | UbitUmarov | 2018-04-09 00:15:45 +0100 |
commit | 63da4d3f99a292aff6963f4d453ec3911be51b62 (patch) | |
tree | b46f96a46d5c2005805afd97641e27e2a74e8a19 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |
parent | .. and yes i forgot a file.. again :( (diff) | |
download | opensim-SC-63da4d3f99a292aff6963f4d453ec3911be51b62.zip opensim-SC-63da4d3f99a292aff6963f4d453ec3911be51b62.tar.gz opensim-SC-63da4d3f99a292aff6963f4d453ec3911be51b62.tar.bz2 opensim-SC-63da4d3f99a292aff6963f4d453ec3911be51b62.tar.xz |
mantis 8305: add several ossl sound funtions that accept a link number for the prim associated to that sound. The link number must point to a single prim
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 193 |
1 files changed, 193 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 253bb06..d81054e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -144,6 +144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
144 | internal bool m_debuggerSafe = false; | 144 | internal bool m_debuggerSafe = false; |
145 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); | 145 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); |
146 | protected IUrlModule m_UrlModule = null; | 146 | protected IUrlModule m_UrlModule = null; |
147 | protected ISoundModule m_SoundModule = null; | ||
147 | internal IConfig m_osslconfig; | 148 | internal IConfig m_osslconfig; |
148 | 149 | ||
149 | public void Initialize( | 150 | public void Initialize( |
@@ -160,6 +161,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
160 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); | 161 | m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); |
161 | 162 | ||
162 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | 163 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); |
164 | m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>(); | ||
165 | |||
163 | if (m_osslconfig.GetBoolean("AllowOSFunctions", false)) | 166 | if (m_osslconfig.GetBoolean("AllowOSFunctions", false)) |
164 | { | 167 | { |
165 | m_OSFunctionsEnabled = true; | 168 | m_OSFunctionsEnabled = true; |
@@ -4832,5 +4835,195 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4832 | double mcross = LSL_Vector.Mag(LSL_Vector.Cross(a,b)); | 4835 | double mcross = LSL_Vector.Mag(LSL_Vector.Cross(a,b)); |
4833 | return Math.Atan2(mcross, dot); | 4836 | return Math.Atan2(mcross, dot); |
4834 | } | 4837 | } |
4838 | |||
4839 | |||
4840 | //******* link sound | ||
4841 | public void osAdjustSoundVolume(LSL_Integer linknum, LSL_Float volume) | ||
4842 | { | ||
4843 | m_host.AddScriptLPS(1); | ||
4844 | SceneObjectPart sop = GetSingleLinkPart(linknum); | ||
4845 | if(sop == null) | ||
4846 | return; | ||
4847 | sop.AdjustSoundGain(volume); | ||
4848 | ScriptSleep(100); | ||
4849 | } | ||
4850 | |||
4851 | public void osSetSoundRadius(LSL_Integer linknum, LSL_Float radius) | ||
4852 | { | ||
4853 | m_host.AddScriptLPS(1); | ||
4854 | SceneObjectPart sop = GetSingleLinkPart(linknum); | ||
4855 | if(sop == null) | ||
4856 | return; | ||
4857 | m_host.SoundRadius = radius; | ||
4858 | } | ||
4859 | |||
4860 | public void osPlaySound(LSL_Integer linknum, LSL_String sound, LSL_Float volume) | ||
4861 | { | ||
4862 | m_host.AddScriptLPS(1); | ||
4863 | |||
4864 | if (m_SoundModule == null) | ||
4865 | return; | ||
4866 | |||
4867 | SceneObjectPart sop = GetSingleLinkPart(linknum); | ||
4868 | if(sop == null) | ||
4869 | return; | ||
4870 | |||
4871 | UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); | ||
4872 | if(soundID == UUID.Zero) | ||
4873 | return; | ||
4874 | |||
4875 | // send the sound, once, to all clients in range | ||
4876 | m_SoundModule.SendSound(sop.UUID, soundID, volume, false, 0, 0, false, false); | ||
4877 | } | ||
4878 | |||
4879 | public void osLoopSound(LSL_Integer linknum, LSL_String sound, LSL_Float volume) | ||
4880 | { | ||
4881 | m_host.AddScriptLPS(1); | ||
4882 | |||
4883 | if (m_SoundModule == null) | ||
4884 | return; | ||
4885 | |||
4886 | SceneObjectPart sop = GetSingleLinkPart(linknum); | ||
4887 | if(sop == null) | ||
4888 | return; | ||
4889 | |||
4890 | UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); | ||
4891 | if(soundID == UUID.Zero) | ||
4892 | return; | ||
4893 | |||
4894 | m_SoundModule.LoopSound(sop.UUID, soundID, volume, 20, false,false); | ||
4895 | } | ||
4896 | |||
4897 | public void osLoopSoundMaster(LSL_Integer linknum, LSL_String sound, LSL_Float volume) | ||
4898 | { | ||
4899 | m_host.AddScriptLPS(1); | ||
4900 | |||
4901 | SceneObjectPart sop = GetSingleLinkPart(linknum); | ||
4902 | if(sop == null) | ||
4903 | return; | ||
4904 | |||
4905 | UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); | ||
4906 | if(soundID == UUID.Zero) | ||
4907 | return; | ||
4908 | |||
4909 | m_SoundModule.LoopSound(sop.UUID, soundID, volume, 20, true, false); | ||
4910 | } | ||
4911 | |||
4912 | public void osLoopSoundSlave(LSL_Integer linknum, LSL_String sound, LSL_Float volume) | ||
4913 | { | ||
4914 | m_host.AddScriptLPS(1); | ||
4915 | |||
4916 | if (m_SoundModule == null) | ||
4917 | return; | ||
4918 | |||
4919 | SceneObjectPart sop = GetSingleLinkPart(linknum); | ||
4920 | if(sop == null) | ||
4921 | return; | ||
4922 | |||
4923 | UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); | ||
4924 | if(soundID == UUID.Zero) | ||
4925 | return; | ||
4926 | |||
4927 | m_SoundModule.LoopSound(sop.UUID, soundID, volume, 20, false, true); | ||
4928 | } | ||
4929 | |||
4930 | public void osPlaySoundSlave(LSL_Integer linknum, LSL_String sound, LSL_Float volume) | ||
4931 | { | ||
4932 | m_host.AddScriptLPS(1); | ||
4933 | |||
4934 | if (m_SoundModule == null) | ||
4935 | return; | ||
4936 | |||
4937 | SceneObjectPart sop = GetSingleLinkPart(linknum); | ||
4938 | if(sop == null) | ||
4939 | return; | ||
4940 | |||
4941 | UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); | ||
4942 | if(soundID == UUID.Zero) | ||
4943 | return; | ||
4944 | |||
4945 | // send the sound, once, to all clients in range | ||
4946 | m_SoundModule.SendSound(sop.UUID, soundID, volume, false, 0, 0, true, false); | ||
4947 | } | ||
4948 | |||
4949 | public void osTriggerSound(LSL_Integer linknum, LSL_String sound, LSL_Float volume) | ||
4950 | { | ||
4951 | m_host.AddScriptLPS(1); | ||
4952 | |||
4953 | if (m_SoundModule == null) | ||
4954 | return; | ||
4955 | |||
4956 | SceneObjectPart sop = GetSingleLinkPart(linknum); | ||
4957 | if(sop == null) | ||
4958 | return; | ||
4959 | |||
4960 | UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); | ||
4961 | if(soundID == UUID.Zero) | ||
4962 | return; | ||
4963 | |||
4964 | // send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory. | ||
4965 | m_SoundModule.SendSound(sop.UUID, soundID, volume, true, 0, 0, false, false); | ||
4966 | } | ||
4967 | |||
4968 | public void osStopSound(LSL_Integer linknum) | ||
4969 | { | ||
4970 | m_host.AddScriptLPS(1); | ||
4971 | |||
4972 | if (m_SoundModule == null) | ||
4973 | return; | ||
4974 | |||
4975 | SceneObjectPart sop = GetSingleLinkPart(linknum); | ||
4976 | if(sop == null) | ||
4977 | return; | ||
4978 | |||
4979 | m_SoundModule.StopSound(sop.UUID); | ||
4980 | } | ||
4981 | |||
4982 | public void osPreloadSound(LSL_Integer linknum, LSL_String sound) | ||
4983 | { | ||
4984 | m_host.AddScriptLPS(1); | ||
4985 | |||
4986 | if (m_SoundModule == null) | ||
4987 | return; | ||
4988 | |||
4989 | SceneObjectPart sop = GetSingleLinkPart(linknum); | ||
4990 | if(sop == null) | ||
4991 | return; | ||
4992 | |||
4993 | UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); | ||
4994 | if(soundID == UUID.Zero) | ||
4995 | return; | ||
4996 | |||
4997 | m_SoundModule.PreloadSound(sop.UUID, soundID, 0); | ||
4998 | ScriptSleep(1000); | ||
4999 | } | ||
5000 | |||
5001 | // get only one part | ||
5002 | private SceneObjectPart GetSingleLinkPart(int linkType) | ||
5003 | { | ||
5004 | if (m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
5005 | return null; | ||
5006 | |||
5007 | switch (linkType) | ||
5008 | { | ||
5009 | case ScriptBaseClass.LINK_SET: | ||
5010 | case ScriptBaseClass.LINK_ALL_OTHERS: | ||
5011 | case ScriptBaseClass.LINK_ALL_CHILDREN: | ||
5012 | return null; | ||
5013 | |||
5014 | case 0: | ||
5015 | case ScriptBaseClass.LINK_ROOT: | ||
5016 | return m_host.ParentGroup.RootPart; | ||
5017 | |||
5018 | case ScriptBaseClass.LINK_THIS: | ||
5019 | return m_host; | ||
5020 | |||
5021 | default: | ||
5022 | if(linkType < 0) | ||
5023 | return null; | ||
5024 | |||
5025 | return m_host.ParentGroup.GetLinkNumPart(linkType); | ||
5026 | } | ||
5027 | } | ||
4835 | } | 5028 | } |
4836 | } | 5029 | } |