Blockland Forums > Modification Help
Using return; to return info?
<< < (2/3) > >>
Red_Guy:

--- Quote from: Daenth on June 10, 2011, 08:43:47 PM ---Huh, but where would you use this?

--- End quote ---
it depends on your addon, and what your trying to do.
Destiny/Zack0Wack0:

--- Quote from: Daenth on June 10, 2011, 08:43:47 PM ---Huh, but where would you use this?

--- End quote ---

--- Code: ---function getClientBL_ID(%client)
{
        return %client.bl_id;
}

--- End code ---
Placid:
Basically, it ends a function and gives back a value so that you can use it in if statements or getting things.

for instance, getWord returns the word specified in the string specified.
Chrono:

--- Quote from: Daenth on June 10, 2011, 08:43:47 PM ---Huh, but where would you use this?

--- End quote ---

You need returns in order to do certain things you probably do regularly.

Such as:
findClientByname("Daenth").whatever
findClientByName does a return;

It's like a shortcut.

Would you rather do a for loop in every function you wanna find someone by name or id?

Edit: Also, getRandom(low,high) also uses return. That's how you actually get data out of it.
otto-san:
I made an illustration based off of what Chrono said.

ya im a artis




The point is, return; is extremely useful and can cut your script's over-complication literally in half
Navigation
Message Index
Next page
Previous page

Go to full version