ID:154878
 
I tried this:

Datum
New()
//do stuff to figure out x
return x


mob
proc
check_value()
var/return_value = new/Datum
world << "[return_value] is what you were looking for!"


However that won't work because the variable only stores the new datum, and not it's return value.

I had to do this instead:
Datum
New(isreal)
if(!isreal) return
//do stuff to figure out x
return x



mob
proc
check_value()
var/Datom/datum = new/Datum()
var/return_value_of_datum = datum.New(1)


That seems ugly though, is there a better way assuming I really want to use a datum in this circumstance?
Why don't you just return the thing directly?

datum
var
Value

proc
ReturnValue()
return "[src.value]"

mob
verb
CheckVar()
world << "[datum.ReturnValue()]"
If you don't need the datum object itself for some later use, it seems like you don't even want a datum there. Care to elaborate on what you're actually doing?
You can't do that nor should you if that's all you are having the datum do. The New proc returns "a reference to a new instance of Type" and won't return anything else. You can do it this way below:

math
New()
..()
proc/calculateSum(a, b)return a + b

mob/verb/test()
var/math/m = new/math
world<<m.calculateSum(5, 3)//returns 8


I don't recommend this at all. If you want to calculate a number do it this way:

proc/Add(A, B)return A + B

mob/verb/test()
world<<Add(5, 3)//returns 8