ID:154861
 
How can I access the mob variables like so?

mob
var
eat = "eating"
sleep = "sleeping"
drink = "drinking"

verb
eat()
sleep()
drink()


proc
info_access()
var/Option_Datum/option = new/Option_Datum
var/info = option.Return_Info() //returns either the text "eat", "sleep", "drink"

//how can I compare 'info' to the variables the mob has, and give the descriptions of each above?


Basically the options datum will return text that directly matches up with the variable, so how can I compare the two, so that I can give the player the information that the variable holds?
A datum's vars variable is an associative list in the "[name]" = value format, so src.vars[info] would give you the value you were looking for.
In response to DarkCampainger
Thanks, got it working!
In response to DarkCampainger
DarkCampainger wrote:
A datum's vars variable is an associative list in the "[name]" = value format, so src.vars[info] would give you the value you were looking for.

heh, I had no idea you could use vars like that. Very cool indeed.