Don't click here unless you want to be banned.

LSL Wiki : return

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are 38.107.191.85

Return

A return is a value given when exiting a function or event. The return keyword is used for exiting from functions or events. If a function has a return value, all code paths will need to end in a return statement.

Note: The term "return value" is used when referring to the value retrieved by calling a function.
Also, there is not currently a function to return objects from a land parcel--that's not what this keyword does.

Example:
MyGlobalFunction(string str) {
    llSay(0, str);
}

float WithReturnValue() {
    float    r;

    r = llFrand(10);
    return r;    // also valid: return(r);
}

default {
    touch_start(integer total_number) {
        if ( llDetectedKey(0) != llGetOwner() ) return; // exit this event if touched by stranger

        MyGlobalFunction("Hooray for SL!"); // call a function without return value

        llSay(0, (string)WithReturnValue()); // call function and use the return value

        WithReturnValue(); // discarding the return value is also legal
    }
}

Flow Control | Glossary
Comments [Hide comments/form]
why do i keep getting "return statement doesnt match function return type"!?!? my function looks like this:
storeTarget(string name)
{
    if(name!="")
    {
        target = name;
        return;
    }
    else
    {
        return(target);
    }
}
-- SchitsoMonkey (2005-07-29 13:13:07)
You're trying to use C style returns...

storeTarget(string name)
{
    if(name!="")
    {
        target = name;
        return "";
    }
    else
    {
        return target;
    }
}
-- KeknehvPsaltery (2005-07-29 15:42:39)
actually, i just figured out the problem
string storeTarget(name)
is how it should look
-- SchitsoMonkey (2005-08-02 11:45:11)
Remember, you still have to define name as a string, though:
string storeTarget(string name)
-- CatherineOmega (2005-08-02 20:50:17)
yeah, sorry that was just a typo
-- SchitsoMonkey (2005-08-05 11:35:15)
Attach a comment to this page: