Well there are well over 400 skills with numeric ids already. I guess I'll just manage with broken cpu ;(
mob/proc/addSkill(skill/skill)
var/idstr = "[skill.id]"
if(!skills)
skills = list()
if(skills[idstr]) return skills[idstr]
skills[idstr] = skill
return skill

mob/proc/getSkill(id)
if(skills) return skills["[id]"]
return null


Well there are well over 400 skills with numeric ids already.

Boom. Problem solved. Numeric ids converted to text on insertion into the list.
In response to Ter13
Would it make a difference if they were global procs with a mob argument instead of mob procs?

proc/addSkill(mob/m,skill/s)
. = "[s.id]"
if(!m.skills) m.skills = list()
if(m.skills[.]) return m.skills[.]
m.skills[.] = s
return null

proc/getSkill(mob/m,id)
if(m.skills) return m.skills["[id]"]
return null

In response to Kozuma3
Kozuma3 wrote:
Would it make a difference if they were global procs with a mob argument instead of mob procs?

Only the fact that that's a terrible design. Look how much you're using "m." in your global version. That's a sign that src has been badly chosen.

Because the skills list is intrinsic to a mob, adding and removing skills should be mob procs, not global ones.
In response to Lummox JR
Lummox JR wrote:
Because the skills list is intrinsic to a mob, adding and removing skills should be mob procs, not global ones.

Understandable.

I was wondering tho when I typed that up if each mob is given the proc or is there only a single proc that all the mobs have access to or however that works.
In response to Kozuma3
Kozuma3 wrote:
Lummox JR wrote:
Because the skills list is intrinsic to a mob, adding and removing skills should be mob procs, not global ones.

Understandable.

I was wondering tho when I typed that up if each mob is given the proc or is there only a single proc that all the mobs have access to or however that works.

It's just a single proc. The prototype is given a list of procs that belong to it. When you call a proc by name, the engine does a lookup from src's type path and up, so all mobs would have this proc. It doesn't take up any more memory than the global proc, and uses less at runtime because it's using one fewer argument.

To put it another way, the proc is part of /mob's definition, not its instances.
In response to Lummox JR
Thank you for clearing that up.
Page: 1 2