ID:178456
 
I'm attempting to create a list of icon_states the player can choose from - not in text form, but using the \icon[] macro option. I'd like to player to see what the icons look like before they choose. Of course, I can't just slap a /icon["Pilgrim"] in there. Is a spread sheet necessary for this to work? What parts of the code should I be paying close attention to while solving this puzzle?

Here's a simplified version of the current code:

world
mob = /mob/create_character

mob
Fighter
icon = 'players.dmi'
icon_state = "fighter"
Cleric
icon = 'players.dmi'
icon_state = "cleric"

create_character
var/mob/character
Login()
switch(input("Who are you?","Icons") in list ("Fighter", "Cleric"))
if("Fighter")
character = new /mob/Fighter()
if("Cleric")
character = new /mob/Cleric()
src.client.mob = character
del(src)

Help me understand what I'm trying to do here. =P All advice greatly appreciated.

-Matic
Create an obj with the icon and icon state you want, such as:
obj/icons
icon = 'whatever.dmi'
warrior
icon_state = "warrior"
McDonaldsGuy
icon_state = "wouldyoulikefrieswiththat"

Then, simply create new objs of each type and put them in a datum var so you only create them once.
var/warrioricon = new /obj/icons/warrior
var/McDonaldsGuyicon = new /obj/icons/McDonaldsGuy

Now, simply set the text macros and you're off.
src << "Available Icons: \icon[warrioricon] \icon[McDonaldsGuy]"

Not very efficient, but it gets the job done.
In response to WizDragon
Thanks for the info, but I must be doing something majorly wrong. My login went from a lame switch w/icon names to an infinite loop! x_x Since I am a "n00b", I may not be inserting your idea into the code correctly. After I listed all the mob's icons and states, I made the warrior icon into an obj like you reccomended.

Then you told me to use a datum var, which only said to use "var/warrioricon = new/obj/icons/warrior" .. now this is the first time I've used datum (at least w/me realizing it), so I simply thought you meant this:

datum
var/warrioricon = new/obj/icons/warrior

That's sitting there all by it's lonesome self, then the mob/Login() starts. I have a funny feeling this caused it. I will read up more on the datum and see if I can figure what I did wrong without need of reply.. but chances are I'll be running back here anyway to get a clearer look.

Thank you again, WizDragon!

btw. Even scarier is somehow it was compiled with 0 errors..?
In response to Matic293
Ok, datum and I are getting along well now. The next problem exists within the use of deadron.characterhandling. At least that's what this error message seems to conclude:

runtime error: Cannot modify null.name.
proc name: Login (/mob/create_character/Login)
source file: CharHandling.dm,63
usr: Matic293 (/mob/create_character)
src: Matic293 (/mob/create_character)
call stack:
Matic293 (/mob/create_character): Login()

When it came time to display the icon in the list, it instead displayed the IMG tag with attributes. Everything was pointing to the proper object, but i'm guessing I need to un-nullify something. If this is the case, I do not want to mess with this intricate library and regret it later.

I throw my soul to the mercy of the gurus once more.
c/` Ooooohhhhhhhhhhmmmmmmmmmmmm c/`
You might consider using a statpanel to display the choosable icons. I don't have any code handy (I'm at work now), but I know it's possible because I've done it in the past!

I think you could also display the icons in the text window -- I don't remember the syntax, but you'd have to first figure out how to display an icon in the text window, then surround that code with a Topic link.

I know this is kind of vague, but you sound like you may only need a nudge in the right direction. If this doesn't help, I'll try to check back later when I have access to my code.
In response to Gughunter
Oops, one more thing: I'm about 95% sure that icons can't be displayed in an input() list. That's why I suggested the other options.