LSL 101/Integers

From Second Life Wiki
< LSL 101
Revision as of 04:42, 29 September 2009 by Blueman Steele (talk | contribs)
Jump to navigation Jump to search
← 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>