diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs | 80 |
1 files changed, 63 insertions, 17 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs index cfd70f4..1fb13a7 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs | |||
@@ -172,6 +172,31 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
172 | return LLUUID.Zero; | 172 | return LLUUID.Zero; |
173 | } | 173 | } |
174 | 174 | ||
175 | |||
176 | /// <summary> | ||
177 | /// accepts a valid LLUUID, -or- a name of an inventory item. | ||
178 | /// Returns a valid LLUUID or LLUUID.Zero if key invalid and item not found | ||
179 | /// in prim inventory. | ||
180 | /// </summary> | ||
181 | /// <param name="k"></param> | ||
182 | /// <returns></returns> | ||
183 | private LLUUID KeyOrName(string k) | ||
184 | { | ||
185 | LLUUID key = LLUUID.Zero; | ||
186 | |||
187 | // if we can parse the string as a key, use it. | ||
188 | if (LLUUID.TryParse(k, out key)) | ||
189 | { | ||
190 | return key; | ||
191 | } | ||
192 | // else try to locate the name in inventory of object. found returns key, | ||
193 | // not found returns LLUUID.Zero which will translate to the default particle texture | ||
194 | else | ||
195 | { | ||
196 | return InventoryKey(k); | ||
197 | } | ||
198 | } | ||
199 | |||
175 | public void osSetRegionWaterHeight(double height) | 200 | public void osSetRegionWaterHeight(double height) |
176 | { | 201 | { |
177 | m_host.AddScriptLPS(1); | 202 | m_host.AddScriptLPS(1); |
@@ -1372,16 +1397,38 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1372 | Deprecated("llSound"); | 1397 | Deprecated("llSound"); |
1373 | } | 1398 | } |
1374 | 1399 | ||
1400 | // Xantor 20080528 PlaySound updated so it accepts an objectinventory name -or- a key to a sound | ||
1401 | // 20080530 Updated to remove code duplication | ||
1375 | public void llPlaySound(string sound, double volume) | 1402 | public void llPlaySound(string sound, double volume) |
1376 | { | 1403 | { |
1377 | m_host.AddScriptLPS(1); | 1404 | m_host.AddScriptLPS(1); |
1378 | m_host.SendSound(sound, volume, false, 0); | 1405 | |
1406 | // send the sound, once, to all clients in range | ||
1407 | m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0); | ||
1379 | } | 1408 | } |
1380 | 1409 | ||
1410 | // Xantor 20080528 we should do this differently. | ||
1411 | // 1) apply the sound to the object | ||
1412 | // 2) schedule full update | ||
1413 | // just sending the sound out once doesn't work so well when other avatars come in view later on | ||
1414 | // or when the prim gets moved, changed, sat on, whatever | ||
1415 | // see large number of mantises (mantes?) | ||
1416 | // 20080530 Updated to remove code duplication | ||
1417 | // 20080530 Stop sound if there is one, otherwise volume only changes don't work | ||
1381 | public void llLoopSound(string sound, double volume) | 1418 | public void llLoopSound(string sound, double volume) |
1382 | { | 1419 | { |
1383 | m_host.AddScriptLPS(1); | 1420 | m_host.AddScriptLPS(1); |
1384 | m_host.SendSound(sound, volume, false, 1); | 1421 | |
1422 | if (m_host.Sound != LLUUID.Zero) | ||
1423 | llStopSound(); | ||
1424 | |||
1425 | m_host.Sound = KeyOrName(sound); | ||
1426 | m_host.SoundGain = volume; | ||
1427 | m_host.SoundFlags = 1; // looping | ||
1428 | m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? | ||
1429 | |||
1430 | m_host.ScheduleFullUpdate(); | ||
1431 | m_host.SendFullUpdateToAllClients(); | ||
1385 | } | 1432 | } |
1386 | 1433 | ||
1387 | public void llLoopSoundMaster(string sound, double volume) | 1434 | public void llLoopSoundMaster(string sound, double volume) |
@@ -1408,10 +1455,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1408 | m_host.SendSound(sound, volume, true, 0); | 1455 | m_host.SendSound(sound, volume, true, 0); |
1409 | } | 1456 | } |
1410 | 1457 | ||
1458 | // Xantor 20080528: Clear prim data of sound instead | ||
1411 | public void llStopSound() | 1459 | public void llStopSound() |
1412 | { | 1460 | { |
1413 | m_host.AddScriptLPS(1); | 1461 | m_host.AddScriptLPS(1); |
1414 | m_host.SendSound(LLUUID.Zero.ToString(), 1.0, false, 2); | 1462 | |
1463 | m_host.Sound = LLUUID.Zero; | ||
1464 | m_host.SoundGain = 0; | ||
1465 | m_host.SoundFlags = 0; | ||
1466 | m_host.SoundRadius = 0; | ||
1467 | |||
1468 | m_host.ScheduleFullUpdate(); | ||
1469 | m_host.SendFullUpdateToAllClients(); | ||
1470 | |||
1471 | // m_host.SendSound(LLUUID.Zero.ToString(), 1.0, false, 2); | ||
1415 | } | 1472 | } |
1416 | 1473 | ||
1417 | public void llPreloadSound(string sound) | 1474 | public void llPreloadSound(string sound) |
@@ -4045,23 +4102,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
4045 | prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; | 4102 | prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; |
4046 | break; | 4103 | break; |
4047 | 4104 | ||
4048 | // Xantor 03-May-2008 | 4105 | // Xantor 20080503 |
4049 | // Wiki: PSYS_SRC_TEXTURE string inventory item name or key of the particle texture | 4106 | // Wiki: PSYS_SRC_TEXTURE string inventory item name or key of the particle texture |
4050 | // "" = default texture. | 4107 | // "" = default texture. |
4108 | // 20080530 Updated to remove code duplication | ||
4051 | case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_TEXTURE: | 4109 | case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_TEXTURE: |
4052 | LLUUID tkey = LLUUID.Zero; | 4110 | prules.Texture = KeyOrName(rules.Data[i + 1].ToString()); |
4053 | |||
4054 | // if we can parse the string as a key, use it. | ||
4055 | if (LLUUID.TryParse(rules.Data[i + 1].ToString(), out tkey)) | ||
4056 | { | ||
4057 | prules.Texture = tkey; | ||
4058 | } | ||
4059 | // else try to locate the name in inventory of object. found returns key, | ||
4060 | // not found returns LLUUID.Zero which will translate to the default particle texture | ||
4061 | else | ||
4062 | { | ||
4063 | prules.Texture = InventoryKey(rules.Data[i+1].ToString()); | ||
4064 | } | ||
4065 | break; | 4111 | break; |
4066 | 4112 | ||
4067 | case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_RATE: | 4113 | case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_RATE: |