[DGD]checking inheritance
boris
boris at locos.com
Fri Aug 4 15:22:00 CEST 2000
Hello !
While coding some LPC, I discovered that it's quite usefull to know
which programs some specific object inherit. For example you can distinguish between NPC and players by checking if the (body)object inherits /std/monster.c or /std/player.c (or whatever files they should inherit on your system).
Anyway here is how I implemented this...
/* this code checks if 'obj' object inherits '/std/some_prog'
program */
if (function_object("some_function", obj) == "/std/some_prog"){
/* obj inherits '/std/some_prog' */
...
} else {
/* obj doesn't inherit '/std/some_prog' */
...
}
Although it works I think it's rather ugly and inefficient way.
This method has problems. Firstly, it requires that the object
has a call_other() callable function, which not always is the case.
Secondly, you must know the exact name of that function. If you
rename or remove that function, this implementation will become
a potential bug.
So I wonder if there is a more elegant way of doing this in DGD-LPC ?
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list