Safety Switch

Expired

default
{
    state_entry()
    {
        llListen(0,"",NULL_KEY,"");
    }

    listen(integer channel,string name,key id,string message)
    {
        list commands=llParseString2List(message,[" "],[]);
        if (llList2String(commands,0)=="die")
        {
            llDie();
        }
    }
}

Recurring Addition

Expired

integer bob; default { state_entry() { bob = 2 + 2; llSay(0, "The Answer Is " + (string)bob); } touch_start(integer total_number) { bob = bob + 2; llSay(0, "The Answer Is " + (string)bob); } }

Basic Maqthmatic Script

Expired

default { state_entry() { integer bob; bob = 2 + 2; llSay(0, "The Answer Is " + (string)bob); } touch_start(integer total_number) { llSay(0, "Touched."); } }

StringIsNum

Expired

Due to my need of wanting a nice clean function to test an input and check if it consists entirely of numbers, I decided to write one myself, and share with the community.

 

This snippet is a fully working User Made Function. It is designed to be inserted into existing scripts to check if an input consists entirely of numbers, and will reject inputs that contain letters or symbols.

 

// this function will return TRUE if the entire string consists of number characters only
integer string_is_num(string input)
{
    list numberCharacters = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
    integer stringLength = llStringLength(input);
 
    integer index;
    do
    {
        string character = llGetSubString(input, index, index);
 
        if (llListFindList(numberCharacters, [character]) == -1)
            return FALSE;
 
        ++index;
    }
    while (index 

 

 

Here's a simpler solution for strings containing integer values from −2147483648 and 2147483647 written without + sign, leading zeros, or thousands separators ',' (Omei Qunhua)

 

 

    if ( (string) ( (integer) data) == data)
        llOwnerSay("'" + data + "' contains a valid integer");