Like say i make a proc
mob
proc
Destroy()
how and when should i call the parent to that proc if its possible?
Is calling the parent ..() only for the build in proc in the DM or can i call the parent for one of mine own proc?
Like say i make a proc mob how and when should i call the parent to that proc if its possible? |
That's the standard example, but calling the "parent proc" doesn't always mean it's the proc defined by the parent type. You can override the same proc twice for the same type of object, or for the same type the proc is defined for.
mob I often use this for the New() proc of objects that BYOND defines. For example, you may have many events that have to happen in world/New() but the events aren't related - it wouldn't make sense to define world/New() once and put all the code there. Instead you can override world/New() every place where it makes sense and call ..() in each one. This way you can put the initialization code for AI in ai.dm and the initialization code for turfs in turfs.dm. When you call ..() it's not calling New() for the parent of world, it's just calling the other places where you've overridden its constructor. |
It combines them all into one proc? Somehow that doesn't seem right. Unless there's something I'm not following.
Also,this is totally the wrong forum. Where the heck are the mods? |
It doesn't combine them into one proc, you have to put ..() in each one to call the previous one. When a proc is invoked, the last definition is used (based on the order they appear in the code files). If you have something like this:
mob When you call mob.something() it'll only print "3" because it executes the last instance of the proc. If you call ..() in that instance, it'll call the previous one (which'll print "2"). |
That will output both lines from both procs when you call MyProc() in a /mob/child, if you removed ..() you'd only have the output from the child proc.