diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index bdacf8b..2842f6b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -439,6 +439,13 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
439 | 439 | ||
440 | set {m_data = value; } | 440 | set {m_data = value; } |
441 | } | 441 | } |
442 | // Function to obtain LSL type from an index. This is needed | ||
443 | // because LSL lists allow for multiple types, and safely | ||
444 | // iterating in them requires a type check. | ||
445 | public Type GetLSLListItemType(int itemIndex) | ||
446 | { | ||
447 | return m_data[itemIndex].GetType(); | ||
448 | } | ||
442 | 449 | ||
443 | // Member functions to obtain item as specific types. | 450 | // Member functions to obtain item as specific types. |
444 | // For cases where implicit conversions would apply if items | 451 | // For cases where implicit conversions would apply if items |
@@ -465,6 +472,10 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
465 | { | 472 | { |
466 | return new LSL_Types.LSLFloat((Double)m_data[itemIndex]); | 473 | return new LSL_Types.LSLFloat((Double)m_data[itemIndex]); |
467 | } | 474 | } |
475 | else if (m_data[itemIndex] is LSL_Types.LSLString) | ||
476 | { | ||
477 | return new LSL_Types.LSLFloat(m_data[itemIndex].ToString()); | ||
478 | } | ||
468 | else | 479 | else |
469 | { | 480 | { |
470 | return (LSL_Types.LSLFloat)m_data[itemIndex]; | 481 | return (LSL_Types.LSLFloat)m_data[itemIndex]; |
@@ -481,20 +492,32 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
481 | { | 492 | { |
482 | return new LSL_Types.LSLString((string)m_data[itemIndex]); | 493 | return new LSL_Types.LSLString((string)m_data[itemIndex]); |
483 | } | 494 | } |
495 | else if (m_data[itemIndex] is LSL_Types.LSLFloat) | ||
496 | { | ||
497 | return new LSL_Types.LSLString((LSLFloat)m_data[itemIndex]); | ||
498 | } | ||
499 | else if (m_data[itemIndex] is LSL_Types.LSLInteger) | ||
500 | { | ||
501 | return new LSL_Types.LSLString((LSLInteger)m_data[itemIndex]); | ||
502 | } | ||
484 | else | 503 | else |
485 | { | 504 | { |
486 | return (LSL_Types.LSLString)m_data[itemIndex]; | 505 | return (LSL_Types.LSLString)m_data[itemIndex]; |
487 | } | 506 | } |
488 | } | 507 | } |
489 | 508 | ||
490 | public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex) | 509 | public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex) |
491 | { | 510 | { |
492 | if (m_data[itemIndex] is LSL_Types.LSLInteger) | 511 | if (m_data[itemIndex] is LSL_Types.LSLInteger) |
493 | return (LSL_Types.LSLInteger)m_data[itemIndex]; | 512 | return (LSL_Types.LSLInteger)m_data[itemIndex]; |
494 | else if (m_data[itemIndex] is Int32) | 513 | if (m_data[itemIndex] is LSL_Types.LSLFloat) |
495 | return new LSLInteger((int)m_data[itemIndex]); | 514 | return new LSLInteger((int)m_data[itemIndex]); |
496 | else | 515 | else if (m_data[itemIndex] is Int32) |
497 | throw new InvalidCastException(); | 516 | return new LSLInteger((int)m_data[itemIndex]); |
517 | else if (m_data[itemIndex] is LSL_Types.LSLString) | ||
518 | return new LSLInteger((string)m_data[itemIndex]); | ||
519 | else | ||
520 | throw new InvalidCastException(); | ||
498 | } | 521 | } |
499 | 522 | ||
500 | public LSL_Types.Vector3 GetVector3Item(int itemIndex) | 523 | public LSL_Types.Vector3 GetVector3Item(int itemIndex) |
@@ -1331,6 +1354,12 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1331 | m_string=s; | 1354 | m_string=s; |
1332 | } | 1355 | } |
1333 | 1356 | ||
1357 | public LSLString(LSLInteger i) | ||
1358 | { | ||
1359 | string s = String.Format("{0}", i); | ||
1360 | m_string = s; | ||
1361 | } | ||
1362 | |||
1334 | #endregion | 1363 | #endregion |
1335 | 1364 | ||
1336 | #region Operators | 1365 | #region Operators |