ID:170781
 
Say if I had this:

mob
verb
Activate()
var/excellency = 0
for(var/obj/J in oview(1))
J.Activated(excellency)
world << "[excellency]"
obj
proc
Activated(excellency)
excellency = rand(1,100)


I find, that this doesn't work as i'd hoped, with 0 being displayed to the world, even when surrounded by objects, any idea what i'm doing wrong?, Or how to pass variables into procs, make the procs modify them, then pass them out?

Thanks in advance.

-Thorg
Put "return excellency" without the quotes at the end of your proc.
DM always passes numbers by value, meaning that changing them within the proc has no effect on their values outside the proc. Objects, however, are always passed by reference, meaning that changing them within the proc changes them everywhere. (That's a crude way of putting it, but it'll do.)

You can get around this by either using return, or by wrapping your number var in an object. (Hint: Lists are objects too.)