ID:145160
 
Code:
obj
Minable_Rocks
var/Rocktype
icon='Turfs.dmi'
density=1
Bronze_Rock
icon_state="Bronze Rock"
Rocktype="Bronze"
Fire_Rock
icon_state="Fire Rock"
Rocktype="Fire"
verb/Mine()
set src in oview(1)
var/GotPik
for(var/obj/Items/Pickaxe/O in usr.contents)
GotPik = 1
if(GotPik)
if(usr.dir==EAST||usr.dir==WEST)
if(usr.y==src.y)
usr.underlays+=image('Items.dmi',"Pickaxe Animation")
usr << "You attemp to mine the [src.Rocktype] Rock..."
sleep(15)
if(prob(50))
usr << "You mine a block of pure [lowertext(src.Rocktype)]."
usr.contents+=text2path("/obj/Minable_Rocks/[src.Rocktype]_Rock")
//^^^^^^^^^^^^^^^^^Not working here^^^^^^^^^^^^^^^^^//
usr.underlays-=image('Items.dmi',"Pickaxe Animation")
return
if(prob(50))
usr << "You failed to mine anything."
usr.underlays-=image('Items.dmi',"Pickaxe Animation")
return
else
usr<<"Try stand to the right(or left) of the rock."
else
usr << "You must be facing right or left to mine."
else
usr << "You don't have a Pickaxe."


Problem description:

I'm trying to make it so when you mine a Rock, it takes the Rock's "Rocktype" variable and puts it into a type path and adds it to your contents. If I don't put "new" in front of "usr.contents+=blahblahblah", I get a "runtime error: cannot append to list" error. If I do, it says text2path is an undefind variable. What do I do to make this work?
You're trying to add a type path to a list that only contains actual objects.

Lummox JR
In response to Lummox JR
Well...How do I make it a real object then?
In response to Xkirby2
var/t=text2path("/obj/Minable_Rocks/[src.Rocktype]_Rock")
if(!t) CRASH("Couldn't make [src.Rocktype] rock.")
new t(usr)
In response to Detnom
Actually, I fixed the problem... I forgot to put certain things in to make it work. :P Oh well. Thanks for your help!