Difference between revisions of "LlGetScriptState"

From Second Life Wiki
Jump to navigation Jump to search
(added example)
m (<lsl> tag to <source>)
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
|inject-2={{LSL Function/inventory|script|uuid=false|type=script}}
|inject-2={{LSL Function/inventory|script|uuid=false|type=script}}
|func_id=250|func_sleep=0.0|func_energy=10.0
|func_id=250|func_sleep=0.0|func_energy=10.0
|func=llGetScriptState|return_type=integer|p1_type=string|p1_name=script
|func=llGetScriptState|return_type=integer|return_subtype=boolean|p1_type=string|p1_name=script
|func_footnote
|func_footnote
|func_desc
|func_desc
|return_text={{HoverLink|boolean|TRUE or FALSE}} that is [[TRUE]] if the {{LSLP|script}} is running.
|return_text=that is [[TRUE]] if the {{LSLP|script}} is running.
|spec
|spec
|caveats
|caveats
|constants
|constants
|examples=
|examples=
<lsl>
<source lang="lsl2">
default
default
{
{
     touch_start(integer num_detected)
     touch_start(integer num_detected)
     {
     {
         integer index = llGetInventoryNumber(INVENTORY_SCRIPT);
         integer numberOfScripts = llGetInventoryNumber(INVENTORY_SCRIPT);


         // start with (total - 1) and end with 0
         integer index;
         while (--index)
         do
         {
         {
             string scriptName = llGetInventoryName(INVENTORY_SCRIPT, index);
             string scriptName = llGetInventoryName(INVENTORY_SCRIPT, index);
             integer scriptState = llGetScriptState(scriptName);
             integer scriptState = llGetScriptState(scriptName);


        //  default value
             string output = "FALSE";
             string output = "FALSE";
        //  else
             if (scriptState) output = "TRUE";
             if (scriptState) output = "TRUE";


Line 30: Line 32:
                 "Script named '" + scriptName + "' has current script state '" + output + "'.");
                 "Script named '" + scriptName + "' has current script state '" + output + "'.");
         }
         }
        while (++index < numberOfScripts);
     }
     }
}
}
</lsl>
</source>
|helpers
|helpers
|also_functions=
|also_functions=
Line 41: Line 44:
|also_articles
|also_articles
|notes
|notes
|history=*There was a time when [[llGetScriptState]] would return [[TRUE]] even if the script had encountered a {{LSLGC|Error|run-time error}}.
|history=*There was a time when [[llGetScriptState]] would return [[TRUE]] even if the script had encountered a {{LSLGC|Error|run-time error}}. This is no longer the case.
|sort=GetScriptState
|sort=GetScriptState
|cat1=Inventory
|cat1=Inventory

Revision as of 02:51, 22 January 2015

Summary

Function: integer llGetScriptState( string script );

Returns a boolean (an integer) that is TRUE if the script is running.

• string script a script in the inventory of the prim this script is in

Caveats

  • If script is missing from the prim's inventory or it is not a script then an error is shouted on DEBUG_CHANNEL.
All Issues ~ Search JIRA for related Bugs

Examples

default
{
    touch_start(integer num_detected)
    {
        integer numberOfScripts = llGetInventoryNumber(INVENTORY_SCRIPT);

        integer index;
        do
        {
            string scriptName = llGetInventoryName(INVENTORY_SCRIPT, index);
            integer scriptState = llGetScriptState(scriptName);

        //  default value
            string output = "FALSE";
        //  else
            if (scriptState) output = "TRUE";

            // PUBLIC_CHANNEL has the integer value 0
            llSay(PUBLIC_CHANNEL,
                "Script named '" + scriptName + "' has current script state '" + output + "'.");
        }
        while (++index < numberOfScripts);
    }
}

See Also

Functions

•  llSetScriptState
•  llResetOtherScript

Deep Notes

History

Search JIRA for related Issues

Signature

function integer llGetScriptState( string script );