Skill
proc
Level(mob/M)
if(M&&exp>=mexp)
for(var/A in unlocked_skills)
var
i = 0
a = 0
params = params2list(unlocked_skills[A])
params2 = params["req"]
newtech = text2path(params["path"])
while(length(params2))
var
skill = copytext(params2,1,findtext(params2,"`"))
numreq = text2num(copytext(params2,length(skill)+2,findtext(params2,"~")))
world<<skill
world<<numreq
for(var/Skill/S in M.contents)
if(skill in M.contents && numreq >= S.level) a ++
params2 = copytext(params2,findtext(params2,"~")+1,length(params2))
world<<params2
i++
if(i == looptimes)break
sleep(1)
world<<"[a] & [i]"
if(a == i && !(newtech in M.othervars[LEARNED]) )
M << "You have learned [params["sname"]]!"
M.othervars[LEARNED] += newtech
M.contents += new newtech
Basic
Starting_Skills
Hand_To_Hand
name="Hand To Hand"skill"
unlocked_skills = list("Adrenaline Rush" = "path= /Skill/Special_Skills/Everyone/Adrenaline&sname=Adrenaline Rush&req=Skill/Basic/Starting_Skills/Hand_To_Hand`10~/Skill/Basic/Starting_Skills/Block`5~/Skill/Basic/Starting_Skills/Evade`5~")
Problem description:
The following Snippet is part of my Skill system for my game.
The problem i'm having is the Level proc when trying to learn something.
I'll explain the problem, and then post the debug.
1: The loop works fine the first 2 times, but doesn't work after that at all(see below)
2: The first skill always begins without "/", even if i use findtext
3: Using the looptimes is bad, but if i don't, it loops infinitly.
4: It doesn't seem to find any of the skills in my contents(even if the requirments are correct), so when the loop is finished, nothing happens.
The Debug.
You feel more experienced with using Hand To Hand.
Skill/Basic/Starting_Skills/Hand_To_Hand
10
/Skill/Basic/Starting_Skills/Block`5~/Skill/Basic/ Starting_Skills/Evade`5
/Skill/Basic/Starting_Skills/Block
5
/Skill/Basic/Starting_Skills/Evade`
/Skill/Basic/Starting_Skills/Evade
/Skill/Basic/Starting_Skills/Evade
0 & 3
As for point 4 (won't find skill in contents), are you just adding a string with the name of the skill to the mob contents, or are you actually adding an instance of the skill datum? If the latter (Edit: a further look at your code seems to show this is true), I believe you'll need to use locate(skill) in M.contents to find it.