Difference between revisions of "FALSE"

From Second Life Wiki
Jump to navigation Jump to search
m (some readability improvements)
(The last edit made complete nonsense of the original example.)
Line 8: Line 8:
integer is_owner(key inputKey)
integer is_owner(key inputKey)
{
{
    key owner = llGetOwner();
     if (inputKey == llGetOwner() )
 
     if (inputKey == owner)
         return TRUE;
         return TRUE;
//  else
//  else
Line 21: Line 19:
     {
     {
         key id = llDetectedKey(0);
         key id = llDetectedKey(0);
        // PUBLIC_CHANNEL has the integer value 0


         if ( is_owner(id) )
         if ( is_owner(id) )
             llSay(PUBLIC_CHANNEL, "Hello, you're my owner!");
             llSay(0, "Hello, you're my owner!");
         else
         else
             llSay(PUBLIC_CHANNEL, "Hello, you're not my owner!");
             llSay(0, "Hello, you're not my owner!");
     }
     }
}
}
</lsl>
</lsl>
<lsl>
<lsl>
say_whether_true_or_false(integer inputInteger)
{
    string outputString = "FALSE";
    if (inputInteger)
//  {
        outputString = "TRUE";
//  }
//  else
//  {
//      we don't need to change the output string anymore
//      because the default was "FALSE"
//  }
//  PUBLIC_CHANNEL has the integer value 0
    llSay(PUBLIC_CHANNEL, "/me [" + llGetScriptName()
        + "]: Boolean has the value '" + outputString + "'.");
}
default
default
{
{
     state_entry()
     state_entry()
     {
     {
         integer boolean = TRUE;
         integer q = TRUE;
 
         if(q)
         if(boolean)
         {
         {
             say_whether_true_or_false(boolean);
             llSay(0, "TRUE");
             boolean = FALSE;
             q = FALSE;
 
             if(!q)
             if(!boolean)//  if FALSE (not TRUE)
             {
             {
                 say_whether_true_or_false(boolean);
                 llSay(0, "FALSE");
                 boolean = TRUE;
                 q = TRUE;
                if(!q)
                    llSay(0, "Won't say this.");


                if(!boolean)//  if FALSE (not TRUE)
//              {
                    say_whether_true_or_false(boolean);
//              }
                 else
                 else
                 {
                 {
                     say_whether_true_or_false(boolean);
                     llSay(0, "TRUE");
                     boolean = FALSE;
                     q = FALSE;
                    if(q)
                        llSay(0, "Won't say this.");


                    if(boolean)
//                  {
                        say_whether_true_or_false(boolean);
//                  }
                     else
                     else
//                  {
                         llSay(0, "FALSE");
                         say_whether_true_or_false(boolean);
//                  }
                 }
                 }
             }
             }
             else
             else
//          {
                 llSay(0, "Won't say this.");
                 say_whether_true_or_false(boolean);
//          }
         }
         }
         else
         else
//      {
             llSay(0, "Won't say this.");
             say_whether_true_or_false(boolean);
//      }
     }
     }
}
}

Revision as of 04:29, 19 January 2013

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) {

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

// else

       return FALSE;

}

default {

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

} </lsl> <lsl> default {

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

} </lsl>

Deep Notes

Search JIRA for related Issues

Signature

integer FALSE = 0;