Difference between revisions of "LSL Addition"

From Second Life Wiki
Jump to navigation Jump to search
m (trying out a different layout to work better with the contents box)
Line 1: Line 1:
{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}}
{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}}
'''this page needs to be templatized for abstraction to other operators after layout is finalized'''
<div style="float:right;">__TOC__</div>
this is only a sample layout, feel free to suggest other layouts.


{{void-box
{{void-box
|title=[[:Category:LSL Operators|Operator]]<nowiki>:</nowiki> ''+''
|title=[[:Category:LSL Operators|Operator]]<nowiki>:</nowiki> ''+''
|content=
|content=
=== This operator affects the following types ===
=== Valid Types: ===
* [[Integer]]: Addition
* [[#Integer|Integer]]
* [[#Vector|Vector]]
* [[#Rotation|Rotation]]
* [[#String|String]]
<!-- Key's don't support addition -->
* [[#List|List]]
}}
 
{{void-box
|title=Integer
|content=
* Operation: Addition
** Example:
** Example:
*** {{HoverText|1|integer}} + {{HoverText|1|integer}}
*** 1 + 1
*** Result = {{HoverText|2|integer}}
*** Result = 2
* [[Float]]: Addition
* See [[#Notes|Note<sup>1</sup>]]
}}
 
{{void-box
|title=Float
|content=
* Operation: Addition
** Example:
** Example:
*** {{HoverText|1.0|float}} + {{HoverText|1.0|float}}
*** 1.5 + 1.5
*** {{HoverText|1.0|float}} + {{HoverText|1|integer}}
*** Result = 3.0
*** {{HoverText|1|integer}} + {{HoverText|1.0|float}}
* See [[#Notes|Note<sup>1</sup>]]
*** Result = {{HoverText|2.0|float}}
}}
* [[Vector]]: Addition
 
{{void-box
|title=Vector
|content=
* Operation: Addition
** Example:
** Example:
*** <1.0, 1.0, 1.0> + <1.0, 0.0, -1.0>
*** <1.0, 1.0, 1.0> + <1.0, 0.0, -1.0>
<!-- probably needs a more explicit a.x + b.x, a.y + b.y, a.z + b.z example -->
*** Result = <2.0, 1.0, 0.0>
*** Result = <2.0, 1.0, 0.0>
* [[Rotation]]: Addition
}}
** Caution:
 
*** This operator is rare used with this type as it is not a meaningful way of combining [[quaternion]]s being used to represent directions.
{{void-box
****Use [[LSL *#Rotation|*]] and [[LSL /#Rotation|/]] instead.
|title=Rotation
|content=
* Operation: unknown!
* See [[#Notes|Note<sup>2</sup>]]
<!-- example ommited because it's rather useless... I don't know why LL allowed this as a valid type, does anyone else? -->
}}
 
{{void-box
|title=String
|content=
* Operation: Concatenation (adds to the end of)
** Example:
** Example:
*** <0.0, 0.0, 0.0, 1.0> + <1.0, 0.0, 0.0, 1.0>
** "abc" + "def"
*** Result = <1.0, 0.0, 0.0, 1.0>
** Result = "abcdef"
<!-- * [[Key]] Key's don't support addition... I'm pretty sure at least. -->
* See [[#Notes|Note<sup>3</sup>]]
* [[String]]: Concatenation
}}
** Example:
 
** "a" + "a"
{{void-box
** Result = "aa"
|title=List
* [[List]]: Concatenation <!-- Needs to be more explicit about mixing types. -->
|content=
* Operation: Concatenation (adds to the end of)
** Example:
** Example:
** [1] + [2]
** [0, 0.0, <0.0, 0.0, 0.0>, ""] + [1, 1.0, <1.0, 1.0, 1.0>, "xyz"]
*** Result = [1, 2]
*** Result = [0, 0.0, <0.0, 0.0, 0.0>, "", 1, 1.0, <1.0, 1.0, 1.0>, "xyz"]
<!-- Needs to be more explicit about mixing types. -->
<!-- concatenation doesn't affect the types stored so it shouldn't be an issue for this page... assignment shorthands might need it. -->
}}
}}


Line 42: Line 76:
|title=Notes
|title=Notes
|content=
|content=
* This operator cannot be used on [[key]]s.
# When one operand is an Integer, and the other is a Float, the Integer is first typecast to Float before addition.
* link article about min/max integer/float values
# This operator is rarely used with this type as it is not a meaningful way of combining [[quaternion]]s being used to represent [[rotation]]s.
* link article about max string, key, and list lengths
#* Use the [[LSL_Multiplication#Rotation|Multiplication]] operator instead.
====Footnotes====
<!-- I'm worried about parsing operation pages by the actual symbols, so am preferring friendly 'common' names for the operator pages, and specifying the actual operation in the description of it's action, especially since there can be multiple operation types with one operator -->
{{Footnotes}}
# While [[Key]]s are a specialized type of [[String]] They cannot be directly used with this operator.
* needs link for article about min/max integer/float values
* needs link for article about max string and list lengths
* '''It'd be helpful if someone wrote a template for this page so that it might be abstracted to other operators after layout is finalized'''
** this is only a sample layout, feel free to suggest other layouts.
}}
}}


[[Category:LSL_Operators]]
[[Category:LSL_Operators]]

Revision as of 11:01, 16 January 2010

Integer

  • Operation: Addition
    • Example:
      • 1 + 1
      • Result = 2
  • See Note1

Float

  • Operation: Addition
    • Example:
      • 1.5 + 1.5
      • Result = 3.0
  • See Note1

Vector

  • Operation: Addition
    • Example:
      • <1.0, 1.0, 1.0> + <1.0, 0.0, -1.0>
      • Result = <2.0, 1.0, 0.0>

Rotation

  • Operation: unknown!
  • See Note2

String

  • Operation: Concatenation (adds to the end of)
    • Example:
    • "abc" + "def"
    • Result = "abcdef"
  • See Note3

List

  • Operation: Concatenation (adds to the end of)
    • Example:
    • [0, 0.0, <0.0, 0.0, 0.0>, ""] + [1, 1.0, <1.0, 1.0, 1.0>, "xyz"]
      • Result = [0, 0.0, <0.0, 0.0, 0.0>, "", 1, 1.0, <1.0, 1.0, 1.0>, "xyz"]

Notes

  1. When one operand is an Integer, and the other is a Float, the Integer is first typecast to Float before addition.
  2. This operator is rarely used with this type as it is not a meaningful way of combining quaternions being used to represent rotations.
  3. While Keys are a specialized type of String They cannot be directly used with this operator.
  • needs link for article about min/max integer/float values
  • needs link for article about max string and list lengths
  • It'd be helpful if someone wrote a template for this page so that it might be abstracted to other operators after layout is finalized
    • this is only a sample layout, feel free to suggest other layouts.