ID:144099
 
Code:
mob/Characters
var
Active_Skill = "Bomb"

proc
Bomb()
world<<"BOOM!"

obj/HUD
Teh_Button
Click()
var/mob/Characters/M = usr

//Now Im Lost...


Problem description: Ok, what I want to happen is to check what my Active_Skill is and call the corresponding proc when I click Teh_Button. As my variable is "Bomb", I want it to call Bomb(). Thanks.

Look up call().

I think what you want is:

mob/Characters
var
Active_Skill = "Bomb"

proc
Bomb()
world<<"BOOM!"

obj/HUD
Teh_Button
Click()
var/mob/Characters/M = usr
call(M,"[M.Active_Skill]")() //the empty brackets are for any arguments you want to pass


I'm actually a bit confused about the syntax, so do make sure you look up call() since I might be wrong and it's useful anyway.

I'm a bit rusty on programming but I don't think you want var/mob/Characters/M = usr. I reckon you want:

obj/HUD
Teh_Button
Click()
var/mob/Characters/M = new
usr = M
call(M,"[M.Active_Skill]")()
Your better off keeping them in a list.
mob
var
list/skills = list("Boom"=/mob/proc/boom,"bang"=/mob/proc/bang)
skilltype
verb
SetSkill()
var/skill = input("Skill") as null|anything in src.skills
if(!skill)return
src.skilltype = skills[skill]
client
Center()
call(usr,usr.skilltype)()
In response to Xx Dark Wizard xX (#2)
Thanks, works fine.
In response to Dice1989 (#3)
so use Call() ,oh
thx a lot,im having this trouble2!!!!
In response to Xx Dark Wizard xX (#2)
If you have it like that, you don't even need an associative list, you could use text2path() instead.