Difference between revisions of "LSL Addition"

From Second Life Wiki
Jump to navigation Jump to search
m (This shouldn't be in flow control, it doesn't control flow.)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}}
{{LSL Header|ml=*}}{{LSLC|Keywords}}{{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.
<!-- 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 -->
{{void-box
|title=[[:Category:LSL Operators|Operator]]<nowiki>:</nowiki> ''+''
|content=
=== Valid Types: ===
* [[#Integer|Integer]]
* [[#Vector|Vector]]
* [[#Rotation|Rotation]]
* [[#String|String]]
<!-- Key's don't support addition -->
* [[#List|List]]
}}


{{void-box
{{void-box
|title=[[:Category:LSL Operators|Operator]]<nowiki>:</nowiki> ''+''
|title=Integer
|content=
|content=
=== This operator affects the following types ===
* Operation: Addition
* [[Integer]]: Addition
** Example:
** Example:
*** {{HoverText|1|integer}} + {{HoverText|1|integer}}
*** 1 + 1
*** Result = {{HoverText|2|integer}}
*** Result = 2
* [[Float]]: Addition
Note: If one variable or value is a float, the integer value will be cast to a float automatically.
** Example:
}}
*** {{HoverText|1.0|float}} + {{HoverText|1.0|float}}
 
*** {{HoverText|1.0|float}} + {{HoverText|1|integer}}
{{void-box
*** {{HoverText|1|integer}} + {{HoverText|1.0|float}}
|title=Float
*** Result = {{HoverText|2.0|float}}
|content=
* [[Vector]]: Addition
* Operation: Addition
** Example:
** Example:
*** 1.5 + 1.5
*** Result = 3.0
Note: If one variable or value is an integer, the integer value will be cast to a float automatically.
}}
{{void-box
|title=Vector
|content=
* Operation: Addition
** Examples:
*** <1.0, 1.0, 1.0> + <1.0, 0.0, -1.0>
*** <1.0, 1.0, 1.0> + <1.0, 0.0, -1.0>
*** Result = <2.0, 1.0, 0.0>
*** Result = <2.0, 1.0, 0.0>
* [[Rotation]]: Addition
*** Action: <a.x, a.y, a.z> + <nowiki><b.x, b.y, b.z></nowiki> == <a.x + b.x, a.y + b.y, a.z + b.z>
** Caution:
*** <-1.0, 0.0, 1.0> + 1.0
*** This operator is rare used with this type as it is not a meaningful way of combining [[quaternion]]s being used to represent directions.
*** Result: <0.0, 1.0, 2.0>
****Use [[LSL *#Rotation|*]] and [[LSL /#Rotation|/]] instead.
*** Action: <a.x, a.y, a.z> + b == <a.x + b, a.y + b, a.z + b>
Note: All elements are floats, if any are written as integers they will be cast to floats automatically
}}
 
{{void-box
|title=Rotation
|content=
* Operation: unknown!
Note: 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. Use Multiplication instead.
<!-- 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. -->
Note: While [[Key]]s are a specialized type of [[String]] They cannot be directly used with this operator.
* [[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"]
*** list + value = [contents_of_list, value]
Note: If the type of the variable or value being added to a list is not a list it will be cast to a list automatically
<!-- 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 82:
|title=Notes
|title=Notes
|content=
|content=
* This operator cannot be used on [[key]]s.
* needs link for article about min/max integer/float values
* link article about min/max integer/float values
* needs link for article about max string and list lengths
* link article about max string, key, 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'''
====Footnotes====
** this is only a sample layout, feel free to suggest other layouts.
{{Footnotes}}
** ''I'll write one when I have some time'' -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]{{!}}[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 22:49, 24 January 2010 (UTC)
}}
}}


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

Latest revision as of 10:31, 4 January 2012

Integer

  • Operation: Addition
    • Example:
      • 1 + 1
      • Result = 2
Note: If one variable or value is a float, the integer value will be cast to a float automatically.

Float

  • Operation: Addition
    • Example:
      • 1.5 + 1.5
      • Result = 3.0
Note: If one variable or value is an integer, the integer value will be cast to a float automatically.

Vector

  • Operation: Addition
    • Examples:
      • <1.0, 1.0, 1.0> + <1.0, 0.0, -1.0>
      • Result = <2.0, 1.0, 0.0>
      • Action: <a.x, a.y, a.z> + <b.x, b.y, b.z> == <a.x + b.x, a.y + b.y, a.z + b.z>
      • <-1.0, 0.0, 1.0> + 1.0
      • Result: <0.0, 1.0, 2.0>
      • Action: <a.x, a.y, a.z> + b == <a.x + b, a.y + b, a.z + b>
Note: All elements are floats, if any are written as integers they will be cast to floats automatically

Rotation

  • Operation: unknown!
Note: This operator is rarely used with this type as it is not a meaningful way of combining quaternions being used to represent rotations. Use Multiplication instead.

String

  • Operation: Concatenation (adds to the end of)
    • Example:
      • "abc" + "def"
      • Result = "abcdef"
Note: While Keys are a specialized type of String They cannot be directly used with this operator.

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"]
      • list + value = [contents_of_list, value]
Note: If the type of the variable or value being added to a list is not a list it will be cast to a list automatically

Notes

  • 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.
    • I'll write one when I have some time -- Strife (talk|contribs) 22:49, 24 January 2010 (UTC)