| Blockland Forums > Modification Help |
| return; |
| << < (2/3) > >> |
| MegaScientifical:
return; lets a command end by telling what called it a result. Example: --- Code: ---function findClientByName(%name) { for (%c = 0; %c < ClientGroup.getCount(); %c++) { %client = ClientGroup.getObject(%c); if(strStr(%client.name, %name)) return %client; } } --- End code --- It also immediately ends the command without continuing, which is what it is most used for. |
| Plornt:
--- Quote from: soba on October 27, 2011, 06:00:24 AM ---I think I get it if(%player.Admin $= "1"); return; The return is triggered if the player has the variable Admin, and it equals 1? , stopping any further functionality after it? can someone confirm this for me? --- End quote --- Since mega had to say some random stuff and didn't answer you, yes that's how it works |
| General:
I don't see what's wrong with Mega's answer? He explained exactly what return does... In case he was unclear, return does exit the function... However it can also, in simple terms, transport a value from a function to another function if a value is inserted in front of "return". For example: --- Code: ---function lol() { return ":I"; } function echoLol() { %valueFromLolFunction = lol(); echo(%valueFromLolFunction); } --- End code --- When the "lol" function is called from the "echoLol" function, the value ":I" is returned to the "lol" function and is echoed into the console. |
| heedicalking:
--- Quote from: General on October 27, 2011, 11:27:08 AM ---I don't see what's wrong with Mega's answer? He explained exactly what return does... --- End quote --- obviously judging by this topic, siba isn't very advanced into scripting. to a novice, mega's post looks like a bunch of crap shoved together. his example isn't some clear cut thing that will be "oh i see it now!" return besically will end the function. function testreturn() { echo("this gets shown"); return; echo("this never gets shown"); } if you type in testreturn(); the echo will not be shown. this is because the return ended the function. |
| MegaScientifical:
Stop hurting my feelings, you guys! I was only trying to help! |
| Navigation |
| Message Index |
| Next page |
| Previous page |