mob/proc/LearnTreeSkill(var/SkillType,var/SkillID)
if(SkillType=="General")
var/obj/Skills/A=new(text2path("/obj/Skills/Attacks/[SkillID]"))
if(!A.SkillCost)
A.SkillCost=1
if(locate(A,src.contents))
src<< "You already know this skill!"
return
if(src.RewardPoints<A.SkillCost)
src<<"You don't have enough Reward Points to purchase this skill!"
return
if(src.RewardPoints>=A.SkillCost)
src.contents+=A
src.RewardPoints-=A.SkillCost
Problem description:
I'm trying to make a Skill Tree of sorts, and this seems to work- except it has the issue of giving me /obj/Skills/ instead of the skill I want to add (in this case, it's obj/Skills/Attacks/Barrage.)
It still deducts the default cost and treats /obj/Skills/ as being in my inventory after I purchase it once, so it seems to not recognize the Attacks/[SkillID] part in general.
Anything I'm doing wrong, here?
This is what I'm using to try to trigger it, I put it in a verb:
usr.LearnTreeSkill("General","Barrage")
You're not creating an object of the type given by text2path(). You're actually creating an object of the variable's type (/obj/Skills) and passing the path as the first argument in the new object's New().
This is proper use of text2path() for creating objects:
You're also not using locate() properly.