character profile using If statements.

I am working on a game where you can choose your gender and Race. I want to set it up so that when the player types in "Look at me" it will list a small bio of the created character and show a portrait of the character as well. Problem is that when you choose say a female character who is say a Halfling, an if statement taking both of those variables into mind would have to be used to generate the proper character portrait. I understand it would be something along the lines of if player.alias is Female and player.race is Halfling then generate the corresponding portrait. I simply don't understand if statements enough to set this up properly, could anyone lend me a hand?


I don't know if it will help you, but here's a sample of my "if" tree which I use as a function "classperspectives" on objects that i'd like to return different descriptions depending upon a player's class and subclass.

SO the main IF and Else IF branches on the tree become the first grouping you want it to check for. "IF Mage" or "Else IF Warrior" and not pictured are the remaining main class groups that are else-ifs until the last else is the most generic description for something that has no class-specific description. Nested in each of these branches is:

another IF tree first set for sets of sub-classes. Maybe that's not in your game and you wouldn't have to worry about it, but in my example to check the sub class "IF Catgician" or "Else IF Fairy" or "Else IF Magefamiliar" and then then the remaining else-ifs are ordinary dual-class mages and then the most generic descriptions of none of the above, but Mage.

I'm using flags, so my tree is checking booleans which will be set on/off depending upon a character's class status.

The third level of nested "IF" in my tree is where you see it acting somewhat like you describe. IF you're only checking two things, then want the attribute that fits. The first example is a very specific character Catgicianwhip That's a character in my game who already meets a complex set of classing-circumstances. It checks if they've got that attribute "if (Getboolean(player, Catgicianwhip)", then also checks for whether the thing looked at has the matching attribute to display a description "and HasScript(this, "catgicianwhipdesc") and the then is "do (this, "catgicianwhipdesc)"

I think in your case, you're looking for "If ((player.race=Halfling) and (player.alias=Female)) {
then do/print whatever attribute you created for that set of circumstances, something like "do (player.HaflingFemale)" but I don't know if you've created all the descriptions yet.

Anyway, for what it's worth, here's a snip from my code and a little breakdown to compare in case it helps you make up yours.

if (GetBoolean(player, "Mage")) {
  if (GetBoolean(player, "Catgician")) {
    if ((GetBoolean(player, "Catgicianwhip") and HasScript(this, "catgicianwhipdesc"))) {
      do (this, "catgicianwhipdesc")
    }
    else if ((GetBoolean(player, "Catgiciantigress") and HasScript(this, "catgiciantigressdesc"))) {
      do (this, "catgiciantigressdesc")
    }
    else if ((GetBoolean(player, "Catarchanist") and HasScript(this, "catarchanistdesc"))) {
      do (this, "catarchanistdesc")
    }
    else if ((GetBoolean(player, "Catillusionist") and HasScript(this, "catillusionistdesc"))) {
      do (this, "catgiciantigressdesc")
    }
    else if ((GetBoolean(player, "Catgicianspiritualist") and HasScript(this, "catgicianspiritualistdesc"))) {
      do (this, "catgicianspiritualistdesc")
    }
    else if ((GetBoolean(player, "Blackcatgician") and HasScript(this, "blackcatgiciandesc"))) {
      do (this, "blackcatgiciandesc")
    }
    else if ((GetBoolean(player, "Catwizard") and HasScript(this, "catwizarddesc"))) {
      do (this, "catwizarddesc")
    }
    else if ((GetBoolean(player, "Cathealer") and HasScript(this, "cathealerdesc"))) {
      do (this, "cathealerdesc")
    }
    else if (HasAttribute(this, "catgiciandesc")) {
      do (this, "catgiciandesc")
    }
    else if (HasScript(this, "magedesc")) {
      do (this, "magedesc")
    }
    else if (HasScript(this, "desc")) {
      do (this, "desc")
    }
    else {
      msg ("{random:It looks ordinary.:You've never seen something like that look so… as expected.:If you'd tried to imagine something unremarkably expected, it would have been what you're seeing now.:I can't describe it to you.}")
    }
  }
  else if (GetBoolean(player, "Fairy")) {
    if ((GetBoolean(player, "Faewarrior") and HasScript(this, "faewarriordesc"))) {
      do (this, "faewarriordesc")
    }
    else if ((GetBoolean(player, "Faecharmer") and HasScript(this, "faecharmerdesc"))) {
      do (this, "faecharmerdesc")
    }
    else if ((GetBoolean(player, "Faearchanist") and HasScript(this, "faearchanistdesc"))) {
      do (this, "faearchanistdesc")
    }
    else if ((GetBoolean(player, "Faeillusionist") and HasScript(this, "faeillusionistdesc"))) {
      do (this, "faeillusionistdesc")
    }
    else if ((GetBoolean(player, "Fairyprincess") and HasScript(this, "fairyprincessdesc"))) {
      do (this, "fairyprincessdesc")
    }
    else if ((GetBoolean(player, "Fairyspiritualist") and HasScript(this, "fairyspiritualistdesc"))) {
      do (this, "fairyspiritualistdesc")
    }
    else if ((GetBoolean(player, "Faedark") and HasScript(this, "faedarkdesc"))) {
      do (this, "faedarkdesc")
    }
    else if ((GetBoolean(player, "Fairywizard") and HasScript(this, "fairywizarddesc"))) {
      do (this, "fairywizarddesc")
    }
    else if ((GetBoolean(player, "Fountainfairy") and HasScript(this, "fountainfairydesc"))) {
      do (this, "fountainfairydesc")
    }
    else if (HasScript(this, "fairydesc")) {
      do (this, "fairydesc")
    }
    else if (HasScript(this, "magedesc")) {
      do (this, "magedesc")
    }
    else if (HasScript(this, "desc")) {
      do (this, "desc")
    }
    else {
      msg ("{random:It looks ordinary.:You've never seen something like that look so… as expected.:If you'd tried to imagine something unremarkably expected, it would have been what you're seeing now.:I can't describe it to you.}")
    }
  }
  else if (GetBoolean(player, "Magefamiliar")) {
    if ((GetBoolean(player, "Magebladefamiliar") and HasScript(this, "magebladefamiliardesc"))) {
      do (this, "magebladefamiliardesc")
    }
    else if ((GetBoolean(player, "Charmerfamiliar") and HasScript(this, "Charmerfamiliardesc"))) {
      do (this, "charmerfamiliardesc")
    }
    else if ((GetBoolean(player, "Archanistfamiliar") and HasScript(this, "archanistfamiliardesc"))) {
      do (this, "archanistfamiliardesc")
    }
    else if ((GetBoolean(player, "Illusionistfamiliar") and HasScript(this, "illusionistfamiliardesc"))) {
      do (this, "illusionistfamiliardesc")
    }
    else if ((GetBoolean(player, "Spiritualistfamiliar") and HasScript(this, "spiritualistfamiliardesc"))) {
      do (this, "spiritualistfamiliardesc")
    }
    else if ((GetBoolean(player, "Occultistblackcatfamiliar") and HasScript(this, "occultistblackcatfamiliardesc"))) {
      do (this, "occultistblackcatfamiliardesc")
    }
    else if ((GetBoolean(player, "Wizardfamiliar") and HasScript(this, "wizardfamiliardesc"))) {
      do (this, "wizardfamiliardesc")
    }
    else if ((GetBoolean(player, "Healerfamiliar") and HasScript(this, "healerfamiliardesc"))) {
      do (this, "healerfamiliardesc")
    }
    else if (HasScript(this, "magefamiliardesc")) {
      do (this, "magefamiliardesc")
    }
    else if (HasScript(this, "magedesc")) {
      do (this, "magedesc")
    }
    else if (HasScript(this, "desc")) {
      do (this, "desc")
    }
    else {
      msg ("{random:It looks ordinary.:You've never seen something like that look so… as expected.:If you'd tried to imagine something unremarkably expected, it would have been what you're seeing now.:I can't describe it to you.}")
    }
  }
  else if ((GetBoolean(player, "Mageblade") and HasScript(this, "magebladedesc"))) {
    do (this, "magebladedesc")
  }
  else if ((GetBoolean(player, "Charmer") and HasScript(this, "charmerdesc"))) {
    do (this, "charmerdesc")
  }
  else if ((GetBoolean(player, "Archanist") and HasScript(this, "archanistdesc"))) {
    do (this, "archanistdesc")
  }
  else if ((GetBoolean(player, "Illusionist") and HasScript(this, "illusionistdesc"))) {
    do (this, "illusionistdesc")
  }
  else if ((GetBoolean(player, "Spiritualist") and HasScript(this, "spiritualistdesc"))) {
    do (this, "spiritualistdesc")
  }
  else if ((GetBoolean(player, "Occultist") and HasScript(this, "occultistdesc"))) {
    do (this, "occultistdesc")
  }
  else if ((GetBoolean(player, "Wizard") and HasScript(this, "wizarddesc"))) {
    do (this, "wizarddesc")
  }
  else if ((GetBoolean(player, "Healer") and HasScript(this, "healerdesc"))) {
    do (this, "healerdesc")
  }
  else if (HasScript(this, "magedesc")) {
    do (this, "magedesc")
  }
  else if (HasScript(this, "desc")) {
    do (this, "desc")
  }
  else {
    msg ("{random:It looks ordinary.:You've never seen something like that look so… as expected.:If you'd tried to imagine something unremarkably expected, it would have been what you're seeing now.:I can't describe it to you.}")
  }
}
else if (GetBoolean(player, "Warrior")) {
  if (GetBoolean(player, "Paladin")) {
    if ((GetBoolean(player, "Paladinbaarcheologist") and HasScript(this, "paladinbaarcheologistdesc"))) {
      do (this, "paladinbaarcheologistdesc")
    }

Mine's probably a bit more complicated than you need. You might do away with having one or two sub-levels, and simply use that last nested bit as an example for each of your else-ifs.


Thinking about this, Mr Angel probably has a much cooler way to generate a character profile. If you play his sample character generation, it creates a wonderful character profile at the end! I'd love to know how his is done!


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums