ID:144654
 
src.stamina -= rand(10,20)
sleep(10)
if(src.training == "Power") src.PWR_EXP += rand(150,500) + src.level
if(src.training == "Ki") src.KI_EXP += rand(60,200) + src.level
if(src.training == "Strength") src.STR_EXP += rand(10,50) + src.level
if(src.training == "Defence") src.DEF_EXP += rand(10,50) + src.level
if(src.training == "Speed") src.SPD_EXP += rand(10,50) + src.level

Id like to make a focus train called "all" so it trains all of your tats but at a very low rate. how?
thx in advance HH


training variable won't work like that because it can't be equal to all those things. You can either make it a list or, in my opinion, the easier way is just to set the variable to "All" like so:

src.stamina -= rand(10,20)
> sleep(10)
> if(src.training == "Power") src.PWR_EXP += rand(150,500) + src.level
> else if(src.training == "Ki") src.KI_EXP += rand(60,200) + src.level
> else if(src.training == "Strength") src.STR_EXP += rand(10,50) + src.level
> else if(src.training == "Defence") src.DEF_EXP += rand(10,50) + src.level
> else if(src.training == "Speed") src.SPD_EXP += rand(10,50) + src.level
> else if(src.training == "All")
src.PWR_EXP += rand(10,50) + src.level
src.KI_EXP += rand(10,50) + src.level
src.STR_EXP += rand(10,50) + src.level
src.DEF_EXP += rand(10,50) + src.level
src.SPD_EXP += rand(10,50) + src.level


I didn't wanna 1 line it all so if you want to you can do that =P and I don't know what a slow rate is... so you'd have to change the numbers on the last part. Anyway, I added elses, no reason to check if training variable is all of them if it can only be equal to one, so else will stop checking for them all once one is true.
In response to VcentG
Yeah but it will do the exact same with just 'if'

overall, you can save space on coding (as well as player load time, and I guess, a tiny tiny tiny tiny bit of lag could be prevented) by just having

if(power
if(strength
if(etc.
if(all
In response to CuriousNeptune
Nah, than he would have to text parse it... I would rather go with bit flags and the ? operator for extending the sleep time (an exampe for the ? operator could be found near the bottom of <http://bwicki.byond.com/ByondBwicki.dmb?TrueFalse>here.

Example of the two I mentioned (it would do you good to understand the above before attempting to read the following):

//setting up values to use for bit flags
#define HEALTH 1//binary: 1
#define POWER 2//10
#define STAMINA 4//100
#define MAGIC 8//1000
#define SPIRIT 16/10000
#define HEAL_ALL (SPIRIT|MAGIC|STAMINA|POWER|HEALTH)//or I could've done 31 for short >_> Binary: 11111

mob/proc/restore(stat)
src.freeze=1
if((stat&HEALTH))//if the bit for HEALTH in stat is ON
hp=mhp
if((stat&POWER))power=mpower
if((stat&STAMINA))stam=maxstam
......finish the rest off....
sleep((stat&HEAL_ALL) ? 20 : 10)//checks if HEAL_ALL was used. If it is, sleep time is 20 msec long, otherwise sleep is for 10 msec long
src.freeze=0


Actually, it would really depend on the style that the training choices were made.

- GhostAnime