Difference between revisions of "LSL 101/Integers"

From Second Life Wiki
Jump to navigation Jump to search
(New page: Category:LSL 101 {{NavNextPrev|prev=Strings and Simple Output|next=The touch_start Event}} Move along. There's nothing to see here, yet.)
 
Line 2: Line 2:
{{NavNextPrev|prev=Strings and Simple Output|next=The touch_start Event}}
{{NavNextPrev|prev=Strings and Simple Output|next=The touch_start Event}}


Move alongThere's nothing to see here, yet.
Integers are whole numbers from −2,147,483,648 and +2,147,483,647Integers can be represented literally in a scripts or placed within a [https://wiki.secondlife.com/wiki/LSL_101/Variables variable] at runtime. To be able to see these numbers however, you'll need to [https://wiki.secondlife.com/wiki/Typecast typcast] then into a string.
 
 
<lsl>
default
{
    state_entry()
    {
        llSay(0, (string)5 );
    }
 
}
</lsl>
 
Why do we preface the number 5 with (string)?  llSay is only expecting a string and will not be able to print a number without you [https://wiki.secondlife.com/wiki/Typecast typcasting] it first. We can do the following.
 
 
<lsl>
default
{
    state_entry()
    {
        llSay(0, "5" );
    }
 
}
</lsl>
 
Here 5 is represented as a string so no typecasting is needed. However in this form it's not really the integer 5 (which can be added and subtracted). Here's an example where math is performed before printing.
 
<lsl>
default
{
    state_entry()
    {
        llSay(0, (string)(2+3) );
    }
 
}
</lsl>

Revision as of 05:42, 29 September 2009

← Strings and Simple Output ↑̲  LSL 101  ̲↑ The touch_start Event →

Integers are whole numbers from −2,147,483,648 and +2,147,483,647. Integers can be represented literally in a scripts or placed within a variable at runtime. To be able to see these numbers however, you'll need to typcast then into a string.


<lsl> default {

   state_entry()
   {
       llSay(0, (string)5 );
   }
  

} </lsl>

Why do we preface the number 5 with (string)? llSay is only expecting a string and will not be able to print a number without you typcasting it first. We can do the following.


<lsl> default {

   state_entry()
   {
       llSay(0, "5" );
   }
  

} </lsl>

Here 5 is represented as a string so no typecasting is needed. However in this form it's not really the integer 5 (which can be added and subtracted). Here's an example where math is performed before printing.

<lsl> default {

   state_entry()
   {
       llSay(0, (string)(2+3) );
   }
  

} </lsl>