ID:180803
 
how do I override a verb?

I want to have a general drop verb for all the objs, specified directly under obj so that it is inherited.

The problem is, I need to specify a special drop for clothing, so that it checks to see if the item is worn. If it is, it should state so and the abort the verb.

How do I do it?
Try this:

obj
verb/drop(bla, bla)
bla, bla
//of course, 'bla, bla' is whatever code you're using

clothing
var/mob/wearer

drop()
if(wearer == usr) usr << "No!"
else . = ..()

I *think* that should work, anyway!
In response to Guy T.
so I should put all the current code within the () of the first drop?

How exactly would that look like with this:

drop()
usr << "You drop [src]"
Move(usr.loc)

will it look like this?

drop(usr << "You drop [src]"; Move(usr.loc))
In response to Kaidorin
On 2/14/01 11:27 am Kaidorin wrote:
so I should put all the current code within the () of the first drop?

How exactly would that look like with this:

drop()
usr << "You drop [src]"
Move(usr.loc)

will it look like this?

drop(usr << "You drop [src]"; Move(usr.loc))

Sorry for the confusion. Just leave your existing drop() as is. The overridden code is what counts. (The line ". = ..()" will call the original code.)
In response to Guy T.
this is the new drop:

drop()
.=..()
if(src.worn==1)
usr << "You will have to remove it first"
return
else
usr << "You drop [src]"
Move(usr.loc)

I get an error telling me that this drop is a duplicate definition, what is wrong?

I tried to put the .=..() in "", then it gave me an error saying: expected statement.
In response to Kaidorin
Note the indentation in my sample code. Since drop() is already defined as a verb under obj, you don't need to refer to it with "verb" under the clothing node. So this should work:

obj
verb/drop()

clothing
drop()

but not this:

obj
verb/drop()

clothing
verb/drop()