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?
ID:180803
![]() Feb 14 2001, 9:16 am (Edited on Feb 14 2001, 9:23 am)
|
|
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)) |
On 2/14/01 11:27 am Kaidorin wrote:
so I should put all the current code within the () of the first drop? Sorry for the confusion. Just leave your existing drop() as is. The overridden code is what counts. (The line ". = ..()" will call the original code.) |
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. |
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!