ID:703924
 
(See the best response by .screw.)
Code:
Pets

Dog
verb
Speak(msg as text)
usr << msg
LoudDog
verb
Speak(msg as text)
usr << msg
..(msg)
Cats


Problem description:
As you see from above, I'm trying to create subclass within a superclass where LoudDog is a Dog and Dog is a Pet. The problem here is when I run it, it says I have a duplicated definition. I'm pretty sure you're allowed to override and/or overload them.

mob
P
verb/history()
world << "P"

O
verb/history()
world << "O"
..() // call P.history()

Problem description:
The code above this one also has the same problem when running it, and I got this from the Help in the Dream Maker.
Can someone explain to me what the problem is here?
When you override procs/verbs, you leave out the "proc/verb" keyword.
mob
P
verb/history()
world << "P"
O
history()
world << "O"
..()

This is what you do when you override any other procedure, like Login(), Move(), etc. You don't type /mob/proc/Login().
Best response
Pets
Dog
LoudDog
SmallDog // an example

verb
Speak(msg as text)
/*
I am placing this verb under the Pets/Dog path
therefore, any further "children" from dog will
also get the verb
*/

usr << msg


mob
P

O
history() // overriding the history verb.
world << "O"
..()

verb
history() // defines it for mob/P/ and further
world << "O"

I see, another question, how do I give the subclass, "LoudDog" characteristics of Dog?
In response to NarutoBleach
NarutoBleach wrote:
I see, another question, how do I give the subclass, "LoudDog" characteristics of Dog?

Can you expand slightly more with that question? What do you mean by characteristics?
In response to NarutoBleach
All children inherit the variables and procedures of all of their parents.

The built-in object tree:
datum
atom
area
turf
movable
obj
mob

If you look in the DM Reference, it provides lists of variables and procedures belonging to all of those nodes, including /datum and /atom/movable. All mobs are datums, atoms, and movable atoms. All objs are also datums, atoms, and movable atoms, but mobs are different from objs in the fact that players can more easily control mobs. Both mobs and objs can move around the map, because that is a property of /atom/movable. Turfs cannot move around, because they are not children of /atom/movable.
By characteristics, I mean the verbs and procs and such.
In response to .screw
.screw wrote:

> mob
> P
>
> O
> history() // overriding the history verb.
> world << "O"
> ..()
>
> verb
> history() // defines it for mob/P/ and further
> world << "O"
>


Wouldn't you be defining verb/history() for mob/ instead since it's only under mob/ not mob/P/?
In response to NarutoBleach
Like I said, children get everything their parents have. If you make something for /mob, all mobs will have it. If you make something for /mob/a, /mob/b won't have it, but /mob/a/h will.
But, how do I assign it to the mob? Like how do I assign "mob/a/h" to someone?
In response to NarutoBleach
An example of it is seen above in .screws code example. You just put the name of your mob type one tab over under mob, then one tab over and under that you define things for that mob type.
In response to NarutoBleach
NarutoBleach wrote:
But, how do I assign it to the mob? Like how do I assign "mob/a/h" to someone?

You're trying to make a player's mob of type "mob/a/h"? If so, that can be done by either changing world/mob to make the default mob type "mob/a/h", or by creating a new mob of type "mob/a/h" and assigning that to client.mob.