ID:178700
 
a bit of help i have read the guide and still dont quite understand "..()" and the "return" command. Just a brief summary of what they both mean would be great help! thx!

- Akarat
return basicly stops an action in it's tracks. ..() is a bit harder to explain, I'll let someone else do that; I'm too tired.
Akarat wrote:
a bit of help i have read the guide and still dont quite understand "..()" and the "return" command. Just a brief summary of what they both mean would be great help! thx!

- Akarat

"return" returns control to the line that called a proc:

proc
do_a()
world << "inside do_a()"
do_b()
world << "back inside do_a()"

do_b()
world << "inside do_b()"
return

It can also return a specific result:

proc
random_color()
return pick("red", "blue", "green", "orange")

You can then use the following elsewhere in your code:

var/my_color = random_color()

Akarat wrote:
a bit of help i have read the guide and still dont quite understand "..()" and the "return" command. Just a brief summary of what they both mean would be great help! thx!


..() is shorthand for the parent or default proc of which the current proc is a variation. This is common when you want to add functionality to an existing proc.

Imagine you want to warn the player not to move his character to the West...

client
West()
src << "I wouldn't go that way if I were you!"

In the above case, the predefined client proc "West()" is overridden, and pressing that key will give the player the warning message, but will not allow them to move.

If instead you wanted to allow them to move, and also give them the message, you would do this:

client
West()
..() // parent proc
src << "I wouldn't go that way if I were you!"

This example first calls the parent (predefined) West() proc, moving the player westward, and then gives him the message.

Now you can probably guess why coders are warned to include ..() in their login code. Login() has a lot of predefined behavior, and if you forget to add in ..(), it all gets skipped, and you end up with a black screen.