Difference between revisions of "FALSE"

From Second Life Wiki
Jump to navigation Jump to search
m
m (added second example)
Line 4: Line 4:
|value=0
|value=0
|desc=Constant used to define the FALSE value in conditional structures or variables/constants in general. Usually it's used because it is more readable, indicating a [[Boolean|boolean]] value instead a [[Integer|integer]] value (0).
|desc=Constant used to define the FALSE value in conditional structures or variables/constants in general. Usually it's used because it is more readable, indicating a [[Boolean|boolean]] value instead a [[Integer|integer]] value (0).
|examples=<lsl>integer q;
|examples=
<lsl>
integer is_owner(key inputKey)
{
    key owner = llGetOwner();
 
    if (inputKey == owner)
        return TRUE;
//  else
        return FALSE;
}
 
default
{
    touch_start(integer num_detected)
    {
        key id = llDetectedKey(0);


        // PUBLIC_CHANNEL has the integer value 0
        if ( is_owner(id) )
            llSay(PUBLIC_CHANNEL, "Hello, you're my owner!");
        else
            llSay(PUBLIC_CHANNEL, "Hello, you're not my owner!");
    }
}
</lsl>
<lsl>
default
default
{
{
     state_entry()
     state_entry()
     {
     {
         q = TRUE;
         integer q = TRUE;
 
         if(q)
         if(q)
         {
         {
             llSay(0, "TRUE");
            // PUBLIC_CHANNEL has the integer value 0
             llSay(PUBLIC_CHANNEL, "TRUE");
 
             q = FALSE;
             q = FALSE;
             if(!q)
             if(!q)
             {
             {
                 llSay(0, "FALSE");
                 llSay(PUBLIC_CHANNEL, "FALSE");
                 q = TRUE;
                 q = TRUE;
                 if(!q)
                 if(!q)
                {
                     llSay(PUBLIC_CHANNEL, "Won't say this.");
                     llSay(0, "Won't say this");
 
                }
                 else
                 else
                 {
                 {
                     llSay(0, "TRUE");
                     llSay(PUBLIC_CHANNEL, "TRUE");
                     q = FALSE;
                     q = FALSE;
                     if(q)
                     if(q)
                    {
                         llSay(PUBLIC_CHANNEL, "Won't say this.");
                         llSay(0, "Won't say this");
 
                    }
                     else
                     else
                    {
                         llSay(PUBLIC_CHANNEL, "FALSE");
                         llSay(0, "FALSE");
                    }
                 }
                 }
             }
             }
             else
             else
            {
                 llSay(PUBLIC_CHANNEL, "Won't say this.");
                 llSay(0, "Won't say this");
            }
         }
         }
         else
         else
        {
             llSay(PUBLIC_CHANNEL, "Won't say this.");
             llSay(0, "Won't say this");
        }
     }
     }
}</lsl>
}
</lsl>
|constants={{LSL ConstRow|TRUE}}
|constants={{LSL ConstRow|TRUE}}
|functions=
|functions=

Revision as of 06:55, 6 October 2012

Description

Constant: integer FALSE = 0;

The integer constant FALSE has the value 0

Constant used to define the FALSE value in conditional structures or variables/constants in general. Usually it's used because it is more readable, indicating a boolean value instead a integer value (0).

Related Articles

Constants

•  TRUE

Articles

•  boolean

Examples

<lsl> integer is_owner(key inputKey) {

   key owner = llGetOwner();
   if (inputKey == owner)
       return TRUE;

// else

       return FALSE;

}

default {

   touch_start(integer num_detected)
   {
       key id = llDetectedKey(0);
       // PUBLIC_CHANNEL has the integer value 0
       if ( is_owner(id) )
           llSay(PUBLIC_CHANNEL, "Hello, you're my owner!");
       else
           llSay(PUBLIC_CHANNEL, "Hello, you're not my owner!");
   }

} </lsl> <lsl> default {

   state_entry()
   {
       integer q = TRUE;
       if(q)
       {
           // PUBLIC_CHANNEL has the integer value 0
           llSay(PUBLIC_CHANNEL, "TRUE");
           q = FALSE;
           if(!q)
           {
               llSay(PUBLIC_CHANNEL, "FALSE");
               q = TRUE;
               if(!q)
                   llSay(PUBLIC_CHANNEL, "Won't say this.");
               else
               {
                   llSay(PUBLIC_CHANNEL, "TRUE");
                   q = FALSE;
                   if(q)
                       llSay(PUBLIC_CHANNEL, "Won't say this.");
                   else
                       llSay(PUBLIC_CHANNEL, "FALSE");
               }
           }
           else
               llSay(PUBLIC_CHANNEL, "Won't say this.");
       }
       else
           llSay(PUBLIC_CHANNEL, "Won't say this.");
   }

} </lsl>

Deep Notes

Search JIRA for related Issues

Signature

integer FALSE = 0;