ID:165779
 
Well I'm looking for a way for a mob to create an object, but not like Building in Icon games or gms summoning/creating them but more like..... A crafting kind of thing! Where you can just make objects if you have certain type of Objects in your inventory. Can someone give me an example about how I would do this?
attatch the verb to the object. For example, put something like this into the code for a log or other craftable item:
verb // note: This should be inside your log obj
craft()
set src in usr.contents // check if item is held
src.loc = null // so that the item vanishes when
// used, in case crafting takes time
// put crafting code here: create new obj and
// tell the player, or make it more complicated.
del src // after completed, delete log permanently

Then the player can activate the "craft" verb and turn the log into something useful. The code for making something useful, of course, is left out - you should be able to fill that in.


--Vito
Vito's is one way of doing it, but I prefer another way. The way I setup mine makes the item seems previously "useless" until you get near a anvil, gain a tool, or whatever you want it atatched to:

var/obj/o = locate(/obj/Item) in src.contents // makes a new var called o = a "Item" in the palyer's content
if(o)//if the object was found in their contents
del(o)//deletes the object
src.contents += new /obj/Item2 //creates a new object, and puts it in their inventory


I also could have sworn this was somewhere under the Developer FAq. If not, I'll be sure to add something..