ID:140219
 
Code:
var/icon/I=new('[P.Type1].dmi')


Problem description:I need the [P.Type1] to be in that special color, like it is when it's between "" but the icon itself needs to be in ''. How can I get it to work? Thanks.

You can not do what you described, since 'filename.extension' does compile-time checking on the resource. In order to reference a file during run-time, you could use file(Path).
In response to Schnitzelnagler
Perhaps I'm just going about it the wrong way then. What I need to do is winset() an image based on the Type1 variable onto a label. Is that possible?

Like if the Type1 variable is Grass, output the Grass.dmi icon into the label.
In response to DisturbedSixx
If you want an image you can just add another map control, and make the image display in that, then you can easily do it, just look up in DM (HUD / screen objects) that will tell you that you can output screen objects to a map control other than that of the default map control.

If you want an image to the label you can set one from the interface file itself as well.

If you want the image to change as well in a label you could also use winset() to hide one label, and show another that has the different image already.

Or you could wait for someone else to tell you how to set the image via winset().
In response to Dan0971
Yeah I am trying to set the image via winset(). I know how to do that without the variable, but with it, I can't get it to work. Thanks for the help anyway though.
In response to Schnitzelnagler
I've tried to use file() and it's not giving me any runtimes but it doesn't work. Am I using it the wrong way?
var/icon/I=file("[P.Type1].dmi")
winset(src,"Type1","image=\ref[I]")
In response to DisturbedSixx
        var/icon/i = new("[P.Type1].dmi")
winset(src, "Type1", "image=\ref[fcopy_rsc(i)]")
In response to Schnitzelnagler
I've tried to use the code but it gives me a bad icon operation runtime. I've tried to change it up a little hoping I can get the problem fixed but no luck. Any idea why?
In response to DisturbedSixx
Does your dmi file contain only a single icon_state with the name ""? Else you might have to refrain to the icon proc, though I'm just guessing here, as the code snippet works perfectly fine with me.
In response to Schnitzelnagler
The file is in a folder called Types and only has one icon_state with no name underneath it. By folder, I mean it's not directly inside of the project folder but in a sub-folder within that.
In response to DisturbedSixx
Oh! Well, then you would have to include the file-path.
In response to Schnitzelnagler
Ah I see, I got it now. Thank you for your help.