ID:149257
 
Let say I have the given setup:

obj
foo
equip
sword
proc
describe()
usr << "Your sword"
armor
proc
describe()
usr << "Your armor"
shield
proc
describe()
usr << "Your shield"
item
ointment
proc
describe()
usr << "Ointment to heal you"


..now, lets say there are instances of these objects stored in an array-like list. Now, whenever I want to call the "describe" proc on one of these items, I try the following:

var obj/foo/myitem = item[2]
myitem.describe()

I get an error on the "foo.describe()" line that says that "describe" is an undefined proc. Note that each "describe" proc may do something totally different. I see why this error exists, but I do not see a way to fix it. Any suggestions?
CableMonkey wrote:
I get an error on the "foo.describe()" line that says that "describe" is an undefined proc. I see why this error exists, but I do not see a way to fix it. Any suggestions?

You can overload procs by doing this kind of declaration:

obj/foo
proc/describe()
sword
describe()
...
shield
describe()
...

then you can access foo.describe() without error.
In response to Tom
Oh yes. That fixed it. I tried something like this during my trial-and-error attempts to fix it, but I redeclared it as a new proc in the armor, shield, sword sections that I used in the example, thus causing a new error.

Thanks Tom.
In response to Tom
That's neat... so by 'pre-defining' the proc directly beneath the parent object, you sorta inherit overloading when you 're-define' it in the child object?
In response to digitalmouse
Yeah, that's basic C++ Inheretance :-)