ID:169836
Apr 24 2005, 2:58 pm
|
|
Last time I asked about Datums and a lot of people helped me out with them. I especially learned a lot from Wizkid and Lummox. But this time I am wondering if you can give me a breif description on the return statements and what they do.
|
In response to Ryne Rekab
|
|
Hey man thanks. <insert happy face here>
|
In response to DragonMasterGod
|
|
DragonMasterGod wrote:
<insert happy face here> :D -Ryan |
In response to Ryne Rekab
|
|
Also. just put "return" with nothing after it. it returns null automaticly
|
I'll try explaining it with a snippet:
proc/return_foo() Any proc that returns something is called a function. You already use many functions without even knowing it! For example, input() and alert() are both functions that return the value which the player picked. Technically speaking, any proc in DM is actually a function. If return is not called manually in a proc, then that proc will return a value of "." (without the quotes). By default, . is equal to null. When return is called, the proc immediately ends, returning the specified value. Therefore, we can do things like the following: atom/proc/get_density() There, the else isn't needed because if the atom's density is equal to 1, then the proc will end right then and there, returning 1. Of course, the above get_density() proc can be done much more efficiently like so: atom/proc/get_density() Any sort of value can be returned, including objects and lists (ie: view())! Often, return is actually used under a conditional in order to end a proc before it reaches the last line: mob/verb/land() |
In response to Wizkidd0123
|
|
Hey Wizkid thanks man.
|
In response to Ryne Rekab
|
|
Roflmao, you inserted the smiling face.
|
In response to Itachi1
|
|
Thanks man.
|
In response to DragonMasterGod
|
|
No way...
-Ryan |
I imagine this is a good example? I know you can return: numbers, text, and list.
-Ryan