ID:272019
 
In order to save writing the same thing out at least 9 times, I searched for a proc that might help. But I was wrong.

I have 9 'Bounty' variables attached to mobs, one for each of the 9 'villages' that players can be from.

So basically, I want to call it like this:

src.(M.Village)Bounty+=100
And if M.Village was "Leaf" the above line would read:
src.LeafHitList+=100

I tried using text2path for this but no luck. :\
You can't access variables that way. What you're looking for is the <code>vars</code> list:

var/variable
if(M.village == "Leaf")
variable = "LeafHitList"
else
variable = "[M.village]Bounty"
src.vars[variable] += 100
In response to DivineO'peanut
Nuts!
I mistyped it in my attempts to make the code as universal as possible.
What I meant to say was this:

src.(M.Village)Bounty+=100
And if M.Village was "Leaf" the above line would read:
src.LeafBounty+=100

But I think that answers my question anyway. Thanks.
In response to DivineO'peanut
Oooh. Run into a new problem.

Same question again, but relating to plain ol' var, as opposed to mob/var or obj/var...

mob/proc/VillageBB_Kill(mob/victim)
var/B = "[victim.Village]Bounty"
src.vars[B] += 300
var/list/H = "[victim.Village]List"
H+=src //type mismatch error.
In response to Saucepan Man
Saucepan Man wrote:
Oooh. Run into a new problem.

Same question again, but relating to plain ol' var, as opposed to mob/var or obj/var...

That's because you aren't setting the list to be equal to anything but a text string.

You probably want var/list/H = src.vars["[victim.Village]List"]

If it's not an src variable but rather a global variable, I don't believe the language has any syntax which would allow you to access it like this. You should find a way to encapsulate it in an object of some kind in that case.