ID:1951128
 
Code:
var/mob/player
list/Skills = new
stat=1

mob/player/proc
skill()
do stuff

obj/skill
icon='stuff'
Click()
usr.skill()


Problem description:

Maybe its my lack of sleep but im stuck...again.....The first goal is to add a skill to a list when a certain stat is hit. The second goal is that this be added to a tab that will contain the users current skills with an icon.

First question is how is the most efficient way to add a skill to a list once requirements are hit? Second question is to achieve the 2nd goal am i wrong in thinking itl be easier and more efficient in creating obj's that call the skill Procs?

Things I am aware of:
setting category--but wont this automatically show it??

Most pref Verbs to call skills--I would too if it can be just as ascetically pleasing and efficient.

I should be able to add it into the LevelUp Proc--But would this still be the most efficient way if i have 40+ skills requiring the same stat?? and how?

I Dont want to just copy and paste code that's why i didn't just post the exact code im referring to, If you need more info please ask
You could try something with lists. Whereby you have a mob list var, that (upon creation) lists all the possible skills they could learn. Each time they learn a skill, remove it from the list. And each time they level up, check through that list. Something like

mob/player/var/list/learnables = list("check_firespell", "check_waterspell","etc")

var/list
PALADIN_SKILLS = list("check_smite","check_holy_persuasion")
BARBARIAN_SKILLS = list("check_shout","check_flailaboutlikeacrazyperson")

mob/proc/setup_learnable_skills()
if(!src.learnables) src.learnables = new
switch(src.class)
if("Paladin")
src.learnables.Add(PALADIN_SKILLS)
if("Barbarian")
src.learnables.Add(BARBARIAN_SKILLS)
if(src.gender == "female")
src.learnables.Add("check_ironing")
if(src.house == "Stark")
src.learnables.Add("check_getting_killed")

/*
A female paladin, who ISNT from house == Stark, would have
a learnable skills list that has:
"check_smite","check_holy_persuasion","check_ironing",
"check_firespell", "check_waterspell","etc"

Notice how they wont have any barbarian skills, or house stark skills.
*/


mob/proc/levelup()
src<<"a stat has increased!"
for(var/x in src.learnables)
call(src,x)()
mob/proc
//notice how check_firespell is the same text as the list items
check_firespell()
if(src.coolness >= 9001)
src<<"You learned a fire spell!"
//the list will be shorter in future
src.learnables.Remove("check_firespell")
if(!src.learnables.len) src.learnables = null
check_waterspell()
// you get the idea

//NOTE: I just made this up on the spot. But should work.




The following method only checks if they meet the requirements when a stat (in this case, strength) grows.
You could go one step further and only check when the player does something (like speaks to an NPC, or rests, or sleeps etc) -- but whether that is called less/more is rather arbitrary.
//I havent used datum stat handling here for simplicity sake.
var
strength
strength_exp
strength_maxexp
mob/proc/TrainStrength(_exp)
src.strength_exp += _exp
if(src.strength_exp >= src.strength_maxexp)
//sort out the exp however your game does
src.strength++
check_learnable_skills()

mob/proc/check_learnable_skills()
if(src.strength>=10)
src<<"You've learned a skill that requires 10 strength!"
//give skill

if(src.strength>=20)
src<<"You've learned a skill that requires 20 strength!"
//give skill

if(src.strength>=25)
src<<"You've learned a skill that requires 25 strength!"
//give skill



As for the other thing about tabs. I don't use them because they're so very ugly. But I know for a fact theres a lib/demo or two in the dev section of byond.
In response to ZOMGbies
I just want to point out something to you about the way you're working with lists; for max efficiency you should cater to list husbandry. Lummox is radical about this. xD
In response to Konlet
Made 2 changes to reflect the article/avoid the wrath of Lummox.

* mob/player/list
* if(!src.learnables.len) src.learnables = null

The two world-var lists are pseudo-const variables... But is that what you meant?
    if(src.gender = "female")
src.learnables.Add("check_ironing")
if(src.house = "Stark")
src.learnables.Add("check_getting_killed")


Not sure if those equals signs are typos or what.
In response to FKI
Got carried away trying to be witty. In my defence I wrote the whole thing in a browser. FIFY
In response to ZOMGbies
In a dev help scenario, it can be difficult to display list husbandry. I was mainly just showing you the tutorial for your own knowledge and future reference.