// Set the attributes.
if (gender == MALE|classes == "Knight")
new_mob.icon ='maleknight.dmi'
else if (gender == MALE|classes == "Warrior")
new_mob.icon ='malewarrior.dmi'
else if (gender == MALE|classes == "Paladin")
new_mob.icon ='malepaladin.dmi'
else if (gender == MALE|classes == "Cleric")
new_mob.icon ='malecleric.dmi'
else if (gender == MALE|classes == "Sage")
new_mob.icon = 'malesage.dmi'
else if (gender == MALE|classes == "Wizard")
new_mob.icon = 'malewizard.dmi'
else if (gender == MALE|classes == "Spellsword")
new_mob.icon = 'malespellsword.dmi'
else if (gender == MALE|classes == "Bard")
new_mob.icon = 'malebard.dmi'
else if (gender == MALE|classes == "Rogue")
new_mob.icon = 'malerogue.dmi'
else if (gender == MALE|classes == "Assasin")
new_mob.icon = 'maleassasin.dmi'
else if (gender == MALE|classes == "Summoner")
new_mob.icon = 'malesummoner.dmi'
else if (gender == MALE|classes == "Soul Caller")
new_mob.icon = 'malesoulcaller.dmi'
else if (gender == FEMALE|classes == "Warrior")
new_mob.icon ='femalewarrior.dmi'
else if (gender == FEMALE|classes == "Paladin")
new_mob.icon ='femalepaladin.dmi'
else if (gender == FEMALE|classes == "Cleric")
new_mob.icon ='femalecleric.dmi'
else if (gender == FEMALE|classes == "Sage")
new_mob.icon = 'femalesage.dmi'
else if (gender == FEMALE|classes == "Wizard")
new_mob.icon = 'femalewizard.dmi'
else if (gender == FEMALE|classes == "Spellsword")
new_mob.icon = 'femalespellsword.dmi'
else if (gender == FEMALE|classes == "Bard")
new_mob.icon = 'femalebard.dmi'
else if (gender == FEMALE|classes == "Rogue")
new_mob.icon = 'femalerogue.dmi'
else if (gender == FEMALE|classes == "Assasin")
new_mob.icon = 'femaleassasin.dmi'
else if (gender == FEMALE|classes == "Summoner")
new_mob.icon = 'femalesummoner.dmi'
else if (gender == FEMALE|classes == "Soul Caller")
new_mob.icon = 'femalesoulcaller.dmi'
right now, even if the code is massive, I am just trying to get it to assign a specific icon to a specific class. As it stands it takes the top most icon for all classes but when I compile it I get no errors.. so somewhere somehow I'm screwing up, lol. Any ideas?
ID:148144
Jun 24 2003, 11:42 pm
|
|
In response to Crispy
|
|
oddly enough there seems to be a problem if I use that.. my generic setup is like this.
switch(char_class) if ("Warrior") new_mob = new /mob/player/Warrior() if ("Knight") new_mob = new /mob/player/Knight() if ("Paladin") new_mob = new /mob/player/Paladin() if ("Cleric") new_mob = new /mob/player/Cleric() if ("Sage") new_mob = new /mob/player/Sage() if ("Wizard") new_mob = new /mob/player/Wizard() if ("Spellsword") new_mob = new /mob/player/Spellsword() if ("Bard") new_mob = new /mob/player/Bard() if ("Rogue") new_mob = new /mob/player/Rogue() if ("Assassin") new_mob = new /mob/player/Assassin() if ("Summoner") new_mob = new /mob/player/Summoner() if ("Soul Caller") new_mob = new /mob/player/SoulCaller // Set the attributes. switch(classes) if ("Knight") if (gender == MALE) new_mob.icon = 'maleknight.dmi' else new_mob.icon = 'femaleknight.dmi' if ("Warrior") if (gender == MALE) new_mob.icon = 'malewarrior.dmi' else new_mob.icon = 'femalewarrior.dmi' if ("Paladin") if (gender == MALE) new_mob.icon = 'malepaladin.dmi' else new_mob.icon = 'femalepaladin.dmi' if ("Cleric") if (gender == MALE) new_mob.icon = 'malecleric.dmi' else new_mob.icon = 'femalecleric.dmi' if ("Sage") if (gender == MALE) new_mob.icon = 'malesage.dmi' else new_mob.icon = 'femalesage.dmi' if ("Wizard") if (gender == MALE) new_mob.icon = 'malewizard.dmi' else new_mob.icon = 'femalewizard.dmi' if ("Spellsword") if (gender == MALE) new_mob.icon = 'malespellsword.dmi' else new_mob.icon = 'femalespellsword.dmi' if ("Bard") if (gender == MALE) new_mob.icon = 'malebard.dmi' else new_mob.icon = 'femalebard.dmi' if ("Rogue") if (gender == MALE) new_mob.icon = 'malerogue.dmi' else new_mob.icon = 'femalerogue.dmi' if ("Assasin") if (gender == MALE) new_mob.icon = 'maleassasin.dmi' else new_mob.icon = 'femaleassasin.dmi' if ("Summoner") if (gender == MALE) new_mob.icon = 'malesummoner.dmi' else new_mob.icon = 'femalesummoner.dmi' if ("Soul Caller") if (gender == MALE) new_mob.icon = 'malesoulcaller.dmi' else new_mob.icon = 'femalesoulcaller.dmi' new_mob.name = char_name new_mob.gender = gender new_mob.Class = char_class new_mob.Level = 1 new_mob.TotalExperience = 0 new_mob.ExperienceNeeded = 1000 new_mob.ArmorClass = 0 new_mob.Delay = 1.5 new_mob.FP_Move(6,8,4) var/obj/Money/O = new /obj/Money/Gold (new_mob) O.Amount = 50 O.suffix = "([O.Amount])" src.client.mob = new_mob del(src) before I was getting space errors and then errors from the var/obj.money. now it doesnt give errors but it shows no icon and all the statpanels are empty. |
In response to Crispy
|
|
Crispy wrote:
&icon="plyricon/[lowertext(gender)][lowertext(classes)]"</ code>> Tada! It's not ideal, but it works. To my knowledge, that actually won't; you'd need to use file() around that icon name to handle it properly. Setting new_mob.icon to a string won't make it load a file. Lummox JR |
In response to SophusVir
|
|
SophusVir wrote:
oddly enough there seems to be a problem if I use that.. my generic setup is like this. Due put else if instead of if and i think u should be fine |
In response to Cloud54367
|
|
actually, I beleive the right way to do it is:
if() else if() else but I'm not sure... |
In response to Dragon of Ice
|
|
actually it uses a switch(class_something) above the if statemens, and as I understand it the "switch" gives me the opportunity to do a big amount of "if" only statements because otherwise I'd have to do only 3 classes IF, Else if, and If. and since I have actualyl 12 classes that just cant handle it :) though your right, if I didnt have the switch i would need those other statements.
I am trying to figure out why that this isnt assigning an icon properly. if (characters.Find(ckey_name)) alert("You already have a character named that! Please choose another name.") src.CreateCharacter() return var/list/classes = new() classes += "Warrior" classes += "Knight" classes += "Paladin" classes += "Cleric" classes += "Sage" classes += "Wizard" classes += "Spellsword" classes += "Bard" classes += "Rogue" classes += "Assassin" classes += "Summoner" classes += "Soul Caller" var/char_class = input("What class is [name]?", "Create Character", null) in classes // Okay we have enough information, so it's time to create the character and switch the player to it. var/mob/new_mob switch(char_class) if ("Warrior") new_mob = new /mob/player/Warrior() if ("Knight") new_mob = new /mob/player/Knight() if ("Paladin") new_mob = new /mob/player/Paladin() if ("Cleric") new_mob = new /mob/player/Cleric() if ("Sage") new_mob = new /mob/player/Sage() if ("Wizard") new_mob = new /mob/player/Wizard() if ("Spellsword") new_mob = new /mob/player/Spellsword() if ("Bard") new_mob = new /mob/player/Bard() if ("Rogue") new_mob = new /mob/player/Rogue() if ("Assassin") new_mob = new /mob/player/Assassin() if ("Summoner") new_mob = new /mob/player/Summoner() if ("Soul Caller") new_mob = new /mob/player/SoulCaller // Set the attributes. switch(classes) if ("Knight") if (gender == MALE) new_mob.icon = 'maleknight.dmi' else new_mob.icon = 'femaleknight.dmi' if ("Warrior") if (gender == MALE) new_mob.icon = 'malewarrior.dmi' else new_mob.icon = 'femalewarrior.dmi' if ("Paladin") if (gender == MALE) new_mob.icon = 'malepaladin.dmi' else new_mob.icon = 'femalepaladin.dmi' if ("Cleric") if (gender == MALE) new_mob.icon = 'malecleric.dmi' else new_mob.icon = 'femalecleric.dmi' if ("Sage") if (gender == MALE) new_mob.icon = 'malesage.dmi' else new_mob.icon = 'femalesage.dmi' if ("Wizard") if (gender == MALE) new_mob.icon = 'malewizard.dmi' else new_mob.icon = 'femalewizard.dmi' if ("Spellsword") if (gender == MALE) new_mob.icon = 'malespellsword.dmi' else new_mob.icon = 'femalespellsword.dmi' if ("Bard") if (gender == MALE) new_mob.icon = 'malebard.dmi' else new_mob.icon = 'femalebard.dmi' if ("Rogue") if (gender == MALE) new_mob.icon = 'malerogue.dmi' else new_mob.icon = 'femalerogue.dmi' if ("Assasin") if (gender == MALE) new_mob.icon = 'maleassasin.dmi' else new_mob.icon = 'femaleassasin.dmi' if ("Summoner") if (gender == MALE) new_mob.icon = 'malesummoner.dmi' else new_mob.icon = 'femalesummoner.dmi' if ("Soul Caller") if (gender == MALE) new_mob.icon = 'malesoulcaller.dmi' else new_mob.icon = 'femalesoulcaller.dmi' new_mob.name = char_name new_mob.gender = gender new_mob.Class = char_class new_mob.Level = 1 new_mob.TotalExperience = 0 new_mob.ExperienceNeeded = 1000 new_mob.ArmorClass = 0 new_mob.Delay = 1.5 new_mob.FP_Move(6,8,4) var/obj/Money/O = new /obj/Money/Gold (new_mob) O.Amount = 50 O.suffix = "([O.Amount])" // Now switch the player client over to the new mob and delete myself since I'm no longer needed. src.client.mob = new_mob del(src) it gives the stats and such fine, but no icon. |
In response to Lummox JR
|
|
Lummox JR wrote:
To my knowledge, that actually won't; you'd need to use file() around that icon name to handle it properly. Setting new_mob.icon to a string won't make it load a file. Whoops, my mistake. That file() proc really annoys me sometimes. =) |
In response to SophusVir
|
|
SophusVir wrote:
switch(classes) That should be "switch(char_class)". "classes" is the list. =) |
Those if()s are just ugly, though, so let me introduce you to the second-most useful decision-making statement: switch().
<code>switch(classes) if ("Knight") if (gender==MALE) new_mob.icon='maleknight.dmi' else new_mob.icon='femaleknight.dmi' if ("Warrior") if (gender==MALE) new_mob.icon='malewarrior.dmi' else new_mob.icon='femalewarrior.dmi' // and so on</code>
Of course, this is still way too lengthy and horrible. Ideally, you would do something like this:
&;new_mob.icon="[lowertext(gender)][lowertext(classes)]"</ code>
(The lowertext(gender) bit works because the MALE and FEMALE constants are actually set to "MALE" and "FEMALE" respectively.)
Unfortunately, that won't work within single quotes, so you have to use double quotes. The drawback of this method is that the game host will need to have all of the DMI files. There is an option when you package the game to include extra files, so you'd put them in there.
Of course, it's quite a pain to list every single relevant DMI file there, so I suggest you move all of those icons into a subdirectory - let's call it "plyricon". Then you can just enter "plyricon/" into that Package Files field, and substitute one line for that humongous mess:
&icon="plyricon/[lowertext(gender)][lowertext(classes)]"</ code>
Tada! It's not ideal, but it works.
The easy way out is to have a single DMI file for all players icons and have different icon_states for each class and gender. But then you run into all sorts of problems when you try to change the icon_state later on.