ID:951607
 
(See the best response by Kaiochao.)
Problem description:
Hello, I was wondering if it was possible to have variables/escaped characters in a dmi definition. Essentially, I'm trying to define classes in a grid and have the mob define its icon based on the class name. Is this possible?
Can you show us an example.
mob
player
New()
..()
sleep(1)
var/SpawnLocations = new/list
for(var/area/A in world)
if(A.Spawnable == 1)
SpawnLocations += A
world << "Area [A] added to list"
usr.name = input(usr,"Please enter a name.","Your name",usr.name)
var/area/Spawn = input("Where do you wish to begin your journey?","Starting location") in SpawnLocations
var/Choices = new/list()
switch(alert(" ","Class Selection","Select a Class","Create a Class"))
if("Select a Class")
for(var/i=1,i<=Spawn.Classes.len,i++)
if(Spawn.Classes[i][1] != null)
Choices += Spawn.Classes[i][1]
world << "[Spawn.Classes[i][1]] added to list"
if("Create a Class")
alert("Sorry, that's not available yet","","OK")
src.Stats[40][1] = input("","Class Selection") in Choices
Stats[40][2] = "'[Stats[40][1]].dmi'"//<----This general area
icon = file(Stats[40][2])//<------------------
src.Move(locate(Spawn.SX,Spawn.SY,Spawn.SZ))
Is this anything helpful?
Not really. I'm trying to avoid defining the icon in an individual mob for the class, and instead calling the icon based on the name of the class (which is stored in Stats[40][1], just to be clear). Know of any way to use file() in the icon call?
icon = file(Stats[40][2])
Best response
Since you can't have embedded expressions between single quotes, what I usually do is build an associative list. The file() procs won't work here because they look for files in the host file's directory (single quotes grab icons compiled with the game).

It may not be pretty when you have a lot of stuff, but I don't recall a better way.
var icons[] = list(
"Some icon" = 'blah.dmi',
"42icon" = 'bloop.dmi'
)

// ...
var thing = 42
icon = icons["[thing]icon"]
Thanks, that'll work.