ID:2157894
 
(See the best response by Nadrew.)
Code:
gui
parent_type = /HUD
gui
var/face_icon = 'Face_Icon_Image.dmi'


FaceIcon
icon = 'Face Icon Template.dmi'
layer = 9001
screen_loc = "WEST + 1:70,NORTH - 1:1"
FaceIcon_Image
icon = face_icon
screen_loc = "WEST + 1:70,NORTH - 1:1"
layer = 9000


//In diffrent file

mob
proc
Profile_Options()
var/profo=input("What do you want to change","Profile Options") in list("Background","Playby","Face Icon","Cancel")
switch(profo)
if("Cancel")
return
if("Face Icon")
var/myicon = input("Choose any icon file for your face icon.","Face Icon") as icon //brings up a box where you can pick anytype of icon file
usr.face_icon = myicon //makes the variable face_icon the icon you just picked


Problem description:
dm:18:error: face_icon: invalid variable



This is the error i get when putting the icon = face_icon. I am in fact still new to the coding scene and would like to know what i am doing wrong. I am trying to call the face_icon variable that is the icon that the user chooses so it displays on the screen.
Best response
You can't set a variable to a non-constant value at compile-time for one, that's why you're getting the error in question.

Next you're trying to use a variable you've defined for mobs under another datum, which isn't going to work the way you expect. You'll either want to stick with one or the other, leaving it as either part of the GUI settings or a mob variable, then using said variable where needed.

So since you have your /gui datum, I assume you have some kind of variable elsewhere that points to it?

// eg
mob/var/gui/my_gui = new()


So, if that's the case (it should be, otherwise you're not going to be accessing the datum very readily!), you'd access the face_icon variable under /gui like

var/myicon = input(// your stuff here)
my_gui.face_icon = myicon


You'd access the icon in the same way, but for setting the icon of the screen objects to a variable, that can't be done at compile-time (the compiler doesn't know the dynamic value of variables in a way that makes this possible), so you'd need to do it inside of a proc, or something like New(), which is called when the objects are created, by setting it after creating the object.

var/gui/gui/FaceIcon_Image/faceicon_thing = new()
faceicon_thing.icon = face_icon
// Or if you keep it under /gui
faceicon_thing.icon = my_gui.face_icon
client.screen += faceicon_thing


As an addition, you'll want to lower the layer on those screen objects, higher layers are reserved for special things like BACKGROUND_LAYER, stick to around 1000 as your highest layer and you should be safe.
In response to Nadrew
Oh my god you are a life saver. Thank you so much.