when I do:
mob
Bump(mob/M)
usr<<"You bumped [M]
it works, but when I bump into a dense turf its says that why? I didn't call it for turfs...did I?
ID:266260
Oct 21 2001, 10:02 am
|
|
In response to Spuzzum
|
|
Spuzzum wrote:
I didn't call it for turfs...did I? Ok, thats stupid, but thanks! |
In response to Air _King
|
|
Ok, thats stupid, but thanks! No, it's not stupid. What if I decided to write two versions of the same proc? mob/Bump(mob/M) ..() usr << "Blah." mob/Bump(turf/T) for(var/mob/M in T) M << "Blih." This would say Blah to the user, but it would also say Blih to everyone inside a bumped turf. |
In response to Spuzzum
|
|
Spuzzum wrote:
Ok, thats stupid, but thanks! what exactly is ..() i have used it, but never really understod it |
In response to Air _King
|
|
Air _King wrote:
Spuzzum wrote: Whoops, that ..() should have actually been in the second proc. Anyway, what ..() does is run what the procedure originally does. So if I do this: mob/Login() ..() world << "[usr] logged in!" I'm basically telling it to run the normal Login() proc (which puts the user on the map) and then add some additional functionality, a message. If I do this: mob/proc/whatever() usr << "Yadda." mob/special_mob/whatever() ..() usr << "And Yidda too!" then that means to run the first version (which says Yadda) and then add an additional message if src is a special_mob. When you don't include the "..()" it is called overriding. Otherwise, you are just adding to the proc. |
In response to Spuzzum
|
|
Spuzzum wrote:
Ok, thats stupid, but thanks! Wait a minute, DM lets you do this sorta thing now? Last time I tried I got duplicate definition errors :P. |
In response to Theodis
|
|
Wait a minute, DM lets you do this sorta thing now? Last time I tried I got duplicate definition errors :P. You should be able to. I think in your case you did mob/proc/whatever() mob/proc/whatever() when you should have done: mob/proc/whatever() mob/whatever() |
In response to Spuzzum
|
|
Spuzzum wrote:
Wait a minute, DM lets you do this sorta thing now? Last time I tried I got duplicate definition errors :P. In C++ it'll let you do this provided the 2 functions vary in parameters, and that was the functionality I thought you were refering to. |
In response to Theodis
|
|
In C++ it'll let you do this provided the 2 functions vary in parameters, and that was the functionality I thought you were refering to. Gah, mention not that foul thing of evil! |
Actually, you just told it that M will *normally* be a mob. Anything that you bump into is stuck into Bump() as the argument.
You have to use if(ismob(M)) to make sure that what you're bumping is a mob.