ID:180801
 
how do I make it so the verbs available for objs change?

I want the verb wear to be replaced with remove when the obj is worn. This should preferably be done directly under obj/clothes.
On 2/14/01 11:56 am Kaidorin wrote:
how do I make it so the verbs available for objs change?

I want the verb wear to be replaced with remove when the obj is worn. This should preferably be done directly under obj/clothes.

You just keep jumping to those advanced topics, don't ya!

Okay here is the magic...

Procs and verbs are pretty much the same thing...a verb is just a proc that the player can see.

So here is what you do:

1) Create the verb as a proc

2) When you want the player to be able to see it, add that proc to the object's verbs list.

Here's how it looks:

obj/clothes
New()
// Start out with wear as a verb.
src.verbs += /obj/clothes/proc/wear
return ..()

proc
wear()
// This will be used as a verb.
set src in world

// Your wearing code goes here

// Now remove wear() as a verb and add remove().
src.verbs -= /obj/clothes/proc/wear
src.verbs += /obj/clothes/proc/remove

remove()
// This will be used as a verb.
set src in world

// Your remove code goes here

// Now switch back to having the wear() verb.
src.verbs += /obj/clothes/proc/wear
src.verbs -= /obj/clothes/proc/remove


In response to Deadron
doesn't this code make it impossible to wear additional stuff, since once you have put something on the wear verb dissapers.

Is it only the wear verb for the specific obj or for all?
In response to Kaidorin
On 2/14/01 1:05 pm Kaidorin wrote:
doesn't this code make it impossible to wear additional stuff, since once you have put something on the wear verb dissapers.

Is it only the wear verb for the specific obj or for all?

It should only affect the specific object, since the verb is being removed from that object's verbs list.
In response to Guy T.
oh, I see it now...

I should wait a while before asking additional questions, at least until I am sure that I don't understand...


wich is quite often when it comes to DM.


thanks for the help!
In response to Guy T.
I've tried and my code looks like this:

proc
wearing()
removing()
wear(mob/trg)
set src in world
src.worn = 1
usr << "You put on [src], [src.wearfeel]."
src.wearing()
src.verbs -= /obj/clothing/proc/wear
src.verbs += /obj/clothing/proc/remove

remove()
set src in world
removing()
usr << "You remove [src]"
src.worn = 0
//remo = remove src.verbs -= /obj/clothing/proc/remo
src.verbs += /obj/clothing/proc/wear

I get these errors:

code\objects.dm:34:error:world:undefined type
code\objects.dm:38:error:src.verbs:bad var
code\objects.dm:39:error:src.verbs:bad var

what is wrong?

if you need more code to know the problem, just say wich part you need and I'll put it here.
In response to Kaidorin
proc
wearing()
removing()
wear(mob/trg)
set src in world
src.worn = 1
usr << "You put on [src], [src.wearfeel]."
src.wearing()
src.verbs -= /obj/clothing/proc/wear
src.verbs += /obj/clothing/proc/remove

remove()
set src in world
removing()
usr << "You remove [src]"
src.worn = 0
//remo = remove src.verbs -= /obj/clothing/proc/remo
src.verbs += /obj/clothing/proc/wear

Hmm... a couple things come to mind. First, this block of procs is indented more in your actual code, right? The line that shows as "proc" above should really look like:

obj/clothing/proc

Not sure why you'd be getting the "world" error, but for your purposes, you probably want "set src in usr" anyway. That should make the verb apply only to clothing that's in the mob's contents list.
In response to Guy T.
they are indented more.

I tried with usr, but gets the same error:

usr:undefined type

I also get 2 src.verbs:bad var

has it got something to do with the proc not knowing the src?
In response to Kaidorin
oh, never mind.

I solved it, my indention was off.

thanks for keeping on helping me, answering my questions.

and most of all, thanks for giving my char the ability to wear clothes!!