Switch Script Issue: Error running script: Object reference not set to an instance of an object.

I've got a very big perspectives function. Over 200 possible results from "look" on any one object.

I'm starting to put the pieces together and thought a switch-script would be good to choose between the "if" trees which branch off of my eight basic classes.

So far, the first 3 branches work in the switch script. Then I added the 4th the same way I've added the others. And it throws this error for anything on that 4th branch:

          Error running script: Object reference not set to an instance of an object.

The "if" tree works all by itself on an object, but for some reason pasting it into the 4th instance on the switch script is killing it.

Is this a known thing with switch-scripts? Can they only take so many lines of code or something?


Can you show us the code that causes your error?
There seems to be something wrong with it, but there's no easy way to say what it is without seeing the code.

The only significant issue I've seen with switch statements is the handling of null.


Hmmm. Maybe it's a null in an "else" somewhere?

I'll see if I can copy-paste it in here. I just haven't always had the best of luck getting code to show in there. Often times it cuts it out unless I add many spaces before each line.... and that's a lot of work for a longer code! haha.

I'll try to copy-paste for my next post.

As I type this I see that there's another option besides indenting. I'll try surrounding it with the backticks and just add it below in this post! :-)

Which reminds me. When you experts show code in here, sometimes you even color code your text, etc. Dow do you do that?

switch (True) {
  case ((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 {
        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 {
        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 {
        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.}")
    }
  }
  case ((player.Warrior)) {
    if (GetBoolean(player, "Paladin")) {
      if ((GetBoolean(player, "Paladinbaarcheologist") and HasScript(this, "paladinbaarcheologistdesc"))) {
        do (this, "paladinbaarcheologistdesc")
      }
      else if ((GetBoolean(player, "Paladindisciplie") and HasScript(this, "paladindiscipledesc"))) {
        do (this, "paladindiscipledesc")
      }
      else if ((GetBoolean(player, "Paladinpilgrim") and HasScript(this, "paladinpilgrimdesc"))) {
        do (this, "paladinpilgrimdesc")
      }
      else if ((GetBoolean(player, "Highpaladin") and HasScript(this, "highpaladindesc"))) {
        do (this, "highpaladindesc")
      }
      else if (HasAttribute(this, "paladindesc")) {
        do (this, "paladindesc")
      }
      else if (.isopen) {
      }
      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, "Dom")) {
      if ((GetBoolean(player, "Magewhip") and HasScript(this, "magewhipdesc"))) {
        do (this, "magewhipdesc")
      }
      else if ((GetBoolean(player, "Whipassassin") and HasScript(this, "whipassassindesc"))) {
        do (this, "whipassassindesc")
      }
      else if ((GetBoolean(player, "Dombiblebasher") and HasScript(this, "dombiblebasherdesc"))) {
        do (this, "dombiblebasherdesc")
      }
      else if ((GetBoolean(player, "Sadistickiller") and HasScript(this, "sadistickillerdesc"))) {
        do (this, "sadistickillerdesc")
      }
      else if ((GetBoolean(player, "Domhero") and HasScript(this, "domherodesc"))) {
        do (this, "domherodesc")
      }
      else if (HasScript(this, "domdesc")) {
        do (this, "domdesc")
      }
      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, "Catolantigress")) {
      if ((GetBoolean(player, "Catgiciantigress") and HasScript(this, "catgiciantigressdesc"))) {
        do (this, "catgiciantigressdesc")
      }
      else if ((GetBoolean(player, "Tigresshunter") and HasScript(this, "tigresshunterdesc"))) {
        do (this, "tigresshunterdesc")
      }
      else if ((GetBoolean(player, "Catolanassassin") and HasScript(this, "catolanassassindesc"))) {
        do (this, "catolanassassindesc")
      }
      else if ((GetBoolean(player, "Illusionistfamiliar") and HasScript(this, "illusionistfamiliardesc"))) {
        do (this, "illusionistfamiliardesc")
      }
      else if ((GetBoolean(player, "Tigresswarlord") and HasScript(this, "tigresswarlorddesc"))) {
        do (this, "tigresswarlorddesc")
      }
      else if ((GetBoolean(player, "Tigressbiblebasher") and HasScript(this, "tigressbiblebasherdesc"))) {
        do (this, "tigressbiblebasherdesc")
      }
      else if ((GetBoolean(player, "Blackcatolan") and HasScript(this, "blackcatolandesc"))) {
        do (this, "blackcatolandesc")
      }
      else if ((GetBoolean(player, "Tigresserrant") and HasScript(this, "tigresserrantdesc"))) {
        do (this, "tigresserrantdesc")
      }
      else if ((GetBoolean(player, "Tigresswarhero") and HasScript(this, "tigresswarherodesc"))) {
        do (this, "tigresswarherodesc")
      }
      else if (HasScript(this, "catolantigressdesc")) {
        do (this, "catolantigressdesc")
      }
      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, "Hunter") and HasScript(this, "hunterdesc"))) {
      do (this, "hunterdesc")
    }
    else if ((GetBoolean(player, "Assassin") and HasScript(this, "assassindesc"))) {
      do (this, "assassindesc")
    }
    else if ((GetBoolean(player, "Warlord") and HasScript(this, "warlorddesc"))) {
      do (this, "warlorddesc")
    }
    else if ((GetBoolean(player, "Prosperitywarlord") and HasScript(this, "prosperitywarlordesc"))) {
      do (this, "prosperitywarlordesc")
    }
    else if ((GetBoolean(player, "Biblebasher") and HasScript(this, "biblebasherdesc"))) {
      do (this, "biblebasherdesc")
    }
    else if ((GetBoolean(player, "Blackknight") and HasScript(this, "blackknightdesc"))) {
      do (this, "blackknightdesc")
    }
    else if ((GetBoolean(player, "Knighterrant") and HasScript(this, "knighterrantdesc"))) {
      do (this, "knighterrantdesc")
    }
    else if ((GetBoolean(player, "Warhero") and HasScript(this, "warherodesc"))) {
      do (this, "warherodesc")
    }
    else if (HasScript(this, "warriordesc")) {
      do (this, "warriordesc")
    }
    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.}")
    }
  }
  case ((player.Diplomat)) {
    if (GetBoolean(player, "Apologist")) {
      if ((GetBoolean(player, "Philanthropistaplologist") and HasScript(this, "philanthropistapologistdesc"))) {
        do (this, "philanthropistapologistdesc")
      }
      else if ((GetBoolean(player, "Apologistdisciple") and HasScript(this, "apologistdiscipledesc"))) {
        do (this, "apologistdiscipledesc")
      }
      else if ((GetBoolean(player, "Pilgrimaplologist") and HasScript(this, "pilgrimaplologistdesc"))) {
        do (this, "pilgrimaplologistdesc")
      }
      else if ((GetBoolean(player, "Outreacher") and HasScript(this, "outreacherdesc"))) {
        do (this, "outreacherdesc")
      }
      else if (HasScript(this, "apologistdesc")) {
        do (this, "apologistdesc")
      }
      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, "Caitian")) {
      if ((GetBoolean(player, "Caitiancharmer") and HasScript(this, "caitiancharmerdesc"))) {
        do (this, "caitiancharmerdesc")
      }
      else if ((GetBoolean(player, "Caitianuniversalist") and HasScript(this, "caitianuniversalistdesc"))) {
        do (this, "caitianuniversalistdesc")
      }
      else if ((GetBoolean(player, "Caitianembassador") and HasScript(this, "caitianembassadordesc"))) {
        do (this, "caitianembassador")
      }
      else if ((GetBoolean(player, "Caitianhero") and HasScript(this, "caitianherodesc"))) {
        do (this, "caitianherodesc")
      }
      else if (HasScript(this, "caitiandesc")) {
        do (this, "caitiandesc")
      }
      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, "Risian")) {
      if ((GetBoolean(player, "Risianembassador") and HasScript(this, "risianembassadordesc"))) {
        do (this, "risianembassadordesc")
      }
      else if (HasScript(this, "risiandesc")) {
        do (this, "risiandesc")
      }
      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, "Charmer") and HasScript(this, "charmerdesc"))) {
      do (this, "charmerdesc")
    }
    else if ((GetBoolean(player, "Prosperitydiplomat") and HasScript(this, "prosperitydiplomatdesc"))) {
      do (this, "prosperitydiplomatdesc")
    }
    else if ((GetBoolean(player, "Universalist") and HasScript(this, "universalistdesc"))) {
      do (this, "universalistdesc")
    }
    else if ((GetBoolean(player, "Anarchist") and HasScript(this, "anarchistdesc"))) {
      do (this, "anarchistdesc")
    }
    else if ((GetBoolean(player, "Embassador") and HasScript(this, "embassadordesc"))) {
      do (this, "embassadordesc")
    }
    else if ((GetBoolean(player, "Arbitrator") and HasScript(this, "arbitratordesc"))) {
      do (this, "arbitratordesc")
    }
    else if (HasScript(this, "diplomatdesc")) {
      do (this, "diplomatdesc")
    }
    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.}")
    }
  }
  case ((player.Collector)) {
    if (GetBoolean(player, "Baarcheologist")) {
      if ((GetBoolean(player, "Paladinbaarcheologist") and HasScript(this, "paladinbaarcheologistdesc"))) {
        do (this, "paladinbaarcheologistdesc")
      }
      else if ((GetBoolean(player, "Baarcheologistapologist") and HasScript(this, "baarcheologistapologistdesc"))) {
        do (this, "baarcheologistapologistdesc")
      }
      else if ((GetBoolean(player, "Philanthropistbaarcheologist") and HasScript(this, "philanthropistbaarcheologistdesc"))) {
        do (this, "philanthropistbaarcheologistdesc")
      }
      else if ((GetBoolean(player, "Baarcheologistdisciple") and HasScript(this, "baarcheologistdiscipledesc"))) {
        do (this, "baarcheologistdiscipledesc")
      }
      else if ((GetBoolean(player, "Baarcheologistpilgrim") and HasScript(this, "baarcheologistpilgrimdesc"))) {
        do (this, "baarcheologistpilgrimdesc")
      }
      else if (HasScript(this, "baarcheologistdesc")) {
        do (this, "baarcheologistdesc")
      }
      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, "Archanist") and HasScript(this, "archanistdesc"))) {
      do (this, "archanistdesc")
    }
    else if ((GetBoolean(player, "Hunter") and HasScript(this, "hunterdesc"))) {
      do (this, "hunterdesc")
    }
    else if ((GetBoolean(player, "Assassin") and HasScript(this, "assassindesc"))) {
      do (this, "assassindesc")
    }
    else if ((GetBoolean(player, "Thief") and HasScript(this, "thiefdesc"))) {
      do (this, "thiefdesc")
    }
    else if ((GetBoolean(player, "Barcheologist") and HasScript(this, "barcheologistdesc"))) {
      do (this, "barcheologistdesc")
    }
    else if ((GetBoolean(player, "Gothicist") and HasScript(this, "gothicistdesc"))) {
      do (this, "gothicistdesc")
    }
    else if ((GetBoolean(player, "Finder") and HasScript(this, "finderdesc"))) {
      do (this, "finderdesc")
    }
    else if ((GetBoolean(player, "Treasurehunter") and HasScript(this, "treasurehunterdesc"))) {
      do (this, "treasurehunterdesc")
    }
    else if (HasScript(this, "collectdesc")) {
      do (this, "collectdesc")
    }
    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.}")
    }
  }
  case ((player.Ninja)) {
    if (GetBoolean(player, "Pantherninja")) {
      if ((GetBoolean(player, "Pantherillusionist") and HasScript(this, "pantherillusionistdesc"))) {
        do (this, "pantherillusionistdesc")
      }
      else if ((GetBoolean(player, "Pantherassassin") and HasScript(this, "pantherassassindesc"))) {
        do (this, "pantherassassindesc")
      }
      else if ((GetBoolean(player, "Pantherburglar") and HasScript(this, "pantherburglardesc"))) {
        do (this, "pantherburglardesc")
      }
      else if ((GetBoolean(player, "Pantherjesuit") and HasScript(this, "pantherjesuitdesc"))) {
        do (this, "pantherjesuitdesc")
      }
      else if ((GetBoolean(player, "Shadowpanther") and HasScript(this, "shadowpantherdesc"))) {
        do (this, "shadowpantherdesc")
      }
      else if ((GetBoolean(player, "Spypanther") and HasScript(this, "spypantherdesc"))) {
        do (this, "spypantherdesc")
      }
      else if (HasScript(this, "pantherninjadesc")) {
        do (this, "pantherninjadesc")
      }
      else if (HasAttribute(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, "Voyeur")) {
      if ((GetBoolean(player, "Illusionistvoyeur") and HasScript(this, "illusionistvoyeurdesc"))) {
        do (this, "illusionistvoyeurdesc")
      }
      else if ((GetBoolean(player, "Voyeurbib") and HasScript(this, "voyeurbibdesc"))) {
        do (this, "voyeurbibdesc")
      }
      else if ((GetBoolean(player, "Shadowsnmvoyeur") and HasScript(this, "shadowsnmvoyeurdesc"))) {
        do (this, "shadowsnmvoyeurdesc")
      }
      else if ((GetBoolean(player, "Privateeye") and HasScript(this, "privateeyedesc"))) {
        do (this, "privateeyedesc")
      }
      else if (HasScript(this, "voyeurdesc")) {
        do (this, "voyeurdesc")
      }
      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, "Illusionist") and HasScript(this, "illusionistdesc"))) {
      do (this, "illusionistdesc")
    }
    else if ((GetBoolean(player, "Assassin") and HasScript(this, "assassindesc"))) {
      do (this, "assassindesc")
    }
    else if ((GetBoolean(player, "Thief") and HasScript(this, "thiefdesc"))) {
      do (this, "thiefdesc")
    }
    else if ((GetBoolean(player, "Jesuit") and HasScript(this, "jesuitdesc"))) {
      do (this, "jesuitdesc")
    }
    else if ((GetBoolean(player, "Shadow") and HasScript(this, "shadowdesc"))) {
      do (this, "shadowdesc")
    }
    else if ((GetBoolean(player, "Spy") and HasScript(this, "spydesc"))) {
      do (this, "spydesc")
    }
    else if (HasScript(this, "ninjadesc")) {
      do (this, "ninjadesc")
    }
    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.}")
    }
  }
  default {
    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.}")
  }
}

Ok, that should show it. It works up through everything until "case ((player.Collector))"

I tired my eyes out a couple of times looking for a missing "this" or "player" or something, but haven't found it. Also, I've made these lower cases essentially by copy-pasting the "if" tree from the "mage" case and just changing which flag and script we're talking about.

Thanks for any help!


Hmmmm. I see a random "isopen" in there... but not where I discovered the bug. The code seems to have been able to read past that. But I'm still going to go delete that one now as junk.


Wow!

Just in case, I started running tests after removing that random "isopen" and poof. Everything works.

I'm not sure why all the Warrior and Diplomat types worked fine if the issue was in the Paladin (dualperspective of warrior) if script. But now that that "isopen" is gone, it works all the way through to the final default and/or the Ninja Description!

Thanks for being there and asking me to post the code, mrangel. Somehow I was able to see the bad line in forum, but not in quest itself. Probably tired eyes and a fresh format/font.

It works again! Now to add the other cases!

I also see a few places where the "desc" description is left out of a tree, so I'll go fix it there.

How do you change a forum post to "solved?"


I'm not sure why you're using a switch there in any case. I'm pretty sure that usage would be more efficient as an if/else tree.

(The metaphor I tend to use is that if is like flipping through a book until you see the section you're looking for; switch is like making an index. If the expressions for the case statements are constant, like literal strings or numbers, it can just build the index once and reuse it when it comes back to that code. But if the keys are variables like player.Collector, the compiler doesn't know for sure that none of them has changed, so it has to rebuild the index every time)

I can't be sure that this is the case for Quest; I've not looked at the implementation. But generally, switch is only the better option if the keys provided to case are constant.


Ohhh.

Hmmm I wonder if that's part of the problem?

I thought it was working, but after "filling in the blanks" It threw the error again, and this time I don't see a random open in there.

So what you're saying is a "Switch" is like if you want the result to be the same no matter which input variant is? I'll file that away. The examples in the documentation were like different phone numbers reaching different people.

here's my revised code, but it's throwing that error in the switch again. I actually have an if tree version built to the same level, and was copying the sub-groups into the switch.

switch (True) {
  case ((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, "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.}")
    }
  }
  case ((player.Warrior)) {
    if (GetBoolean(player, "Paladin")) {
      if ((GetBoolean(player, "Paladinbaarcheologist") and HasScript(this, "paladinbaarcheologistdesc"))) {
        do (this, "paladinbaarcheologistdesc")
      }
      else if ((GetBoolean(player, "Paladindisciplie") and HasScript(this, "paladindiscipledesc"))) {
        do (this, "paladindiscipledesc")
      }
      else if ((GetBoolean(player, "Paladinpilgrim") and HasScript(this, "paladinpilgrimdesc"))) {
        do (this, "paladinpilgrimdesc")
      }
      else if ((GetBoolean(player, "Highpaladin") and HasScript(this, "highpaladindesc"))) {
        do (this, "highpaladindesc")
      }
      else if (HasAttribute(this, "paladindesc")) {
        do (this, "paladindesc")
      }
      else if (HasScript(this, "warriordesc")) {
        do (this, "warriordesc")
      }
      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, "Dom")) {
      if ((GetBoolean(player, "Magewhip") and HasScript(this, "magewhipdesc"))) {
        do (this, "magewhipdesc")
      }
      else if ((GetBoolean(player, "Whipassassin") and HasScript(this, "whipassassindesc"))) {
        do (this, "whipassassindesc")
      }
      else if ((GetBoolean(player, "Dombiblebasher") and HasScript(this, "dombiblebasherdesc"))) {
        do (this, "dombiblebasherdesc")
      }
      else if ((GetBoolean(player, "Sadistickiller") and HasScript(this, "sadistickillerdesc"))) {
        do (this, "sadistickillerdesc")
      }
      else if ((GetBoolean(player, "Domhero") and HasScript(this, "domherodesc"))) {
        do (this, "domherodesc")
      }
      else if (HasScript(this, "domdesc")) {
        do (this, "domdesc")
      }
      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, "Catolantigress")) {
      if ((GetBoolean(player, "Catgiciantigress") and HasScript(this, "catgiciantigressdesc"))) {
        do (this, "catgiciantigressdesc")
      }
      else if ((GetBoolean(player, "Tigresshunter") and HasScript(this, "tigresshunterdesc"))) {
        do (this, "tigresshunterdesc")
      }
      else if ((GetBoolean(player, "Catolanassassin") and HasScript(this, "catolanassassindesc"))) {
        do (this, "catolanassassindesc")
      }
      else if ((GetBoolean(player, "Tigresswarlord") and HasScript(this, "tigresswarlorddesc"))) {
        do (this, "tigresswarlorddesc")
      }
      else if ((GetBoolean(player, "Tigressbiblebasher") and HasScript(this, "tigressbiblebasherdesc"))) {
        do (this, "tigressbiblebasherdesc")
      }
      else if ((GetBoolean(player, "Blackcatolan") and HasScript(this, "blackcatolandesc"))) {
        do (this, "blackcatolandesc")
      }
      else if ((GetBoolean(player, "Tigresserrant") and HasScript(this, "tigresserrantdesc"))) {
        do (this, "tigresserrantdesc")
      }
      else if ((GetBoolean(player, "Tigresswarhero") and HasScript(this, "tigresswarherodesc"))) {
        do (this, "tigresswarherodesc")
      }
      else if (HasScript(this, "catolantigressdesc")) {
        do (this, "catolantigressdesc")
      }
      else if (HasScript(this, "warriordesc")) {
        do (this, "warriordesc")
      }
      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, "Hunter") and HasScript(this, "hunterdesc"))) {
      do (this, "hunterdesc")
    }
    else if ((GetBoolean(player, "Assassin") and HasScript(this, "assassindesc"))) {
      do (this, "assassindesc")
    }
    else if ((GetBoolean(player, "Warlord") and HasScript(this, "warlorddesc"))) {
      do (this, "warlorddesc")
    }
    else if ((GetBoolean(player, "Prosperitywarlord") and HasScript(this, "prosperitywarlordesc"))) {
      do (this, "prosperitywarlordesc")
    }
    else if ((GetBoolean(player, "Biblebasher") and HasScript(this, "biblebasherdesc"))) {
      do (this, "biblebasherdesc")
    }
    else if ((GetBoolean(player, "Blackknight") and HasScript(this, "blackknightdesc"))) {
      do (this, "blackknightdesc")
    }
    else if ((GetBoolean(player, "Knighterrant") and HasScript(this, "knighterrantdesc"))) {
      do (this, "knighterrantdesc")
    }
    else if ((GetBoolean(player, "Warhero") and HasScript(this, "warherodesc"))) {
      do (this, "warherodesc")
    }
    else if (HasScript(this, "warriordesc")) {
      do (this, "warriordesc")
    }
    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.}")
    }
  }
  case ((player.Diplomat)) {
    if (GetBoolean(player, "Apologist")) {
      if ((GetBoolean(player, "Philanthropistaplologist") and HasScript(this, "philanthropistapologistdesc"))) {
        do (this, "philanthropistapologistdesc")
      }
      else if ((GetBoolean(player, "Apologistdisciple") and HasScript(this, "apologistdiscipledesc"))) {
        do (this, "apologistdiscipledesc")
      }
      else if ((GetBoolean(player, "Pilgrimaplologist") and HasScript(this, "pilgrimaplologistdesc"))) {
        do (this, "pilgrimaplologistdesc")
      }
      else if ((GetBoolean(player, "Outreacher") and HasScript(this, "outreacherdesc"))) {
        do (this, "outreacherdesc")
      }
      else if (HasScript(this, "apologistdesc")) {
        do (this, "apologistdesc")
      }
      else if (HasScript(this, "diplomatdesc")) {
        do (this, "diplomatdesc")
      }
      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, "Caitian")) {
      if ((GetBoolean(player, "Caitiancharmer") and HasScript(this, "caitiancharmerdesc"))) {
        do (this, "caitiancharmerdesc")
      }
      else if ((GetBoolean(player, "Caitianuniversalist") and HasScript(this, "caitianuniversalistdesc"))) {
        do (this, "caitianuniversalistdesc")
      }
      else if ((GetBoolean(player, "Caitianembassador") and HasScript(this, "caitianembassadordesc"))) {
        do (this, "caitianembassador")
      }
      else if ((GetBoolean(player, "Caitianhero") and HasScript(this, "caitianherodesc"))) {
        do (this, "caitianherodesc")
      }
      else if (HasScript(this, "caitiandesc")) {
        do (this, "caitiandesc")
      }
      else if (HasScript(this, "diplomatdesc")) {
        do (this, "diplomatdesc")
      }
      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, "Risian")) {
      if ((GetBoolean(player, "Risianembassador") and HasScript(this, "risianembassadordesc"))) {
        do (this, "risianembassadordesc")
      }
      else if (HasScript(this, "risiandesc")) {
        do (this, "risiandesc")
      }
      else if (HasScript(this, "diplomatdesc")) {
        do (this, "diplomatdesc")
      }
      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, "Charmer") and HasScript(this, "charmerdesc"))) {
      do (this, "charmerdesc")
    }
    else if ((GetBoolean(player, "Prosperitydiplomat") and HasScript(this, "prosperitydiplomatdesc"))) {
      do (this, "prosperitydiplomatdesc")
    }
    else if ((GetBoolean(player, "Universalist") and HasScript(this, "universalistdesc"))) {
      do (this, "universalistdesc")
    }
    else if ((GetBoolean(player, "Anarchist") and HasScript(this, "anarchistdesc"))) {
      do (this, "anarchistdesc")
    }
    else if ((GetBoolean(player, "Embassador") and HasScript(this, "embassadordesc"))) {
      do (this, "embassadordesc")
    }
    else if ((GetBoolean(player, "Arbitrator") and HasScript(this, "arbitratordesc"))) {
      do (this, "arbitratordesc")
    }
    else if (HasScript(this, "diplomatdesc")) {
      do (this, "diplomatdesc")
    }
    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.}")
    }
  }
  case ((player.Collector)) {
    if (GetBoolean(player, "Baarcheologist")) {
      if ((GetBoolean(player, "Paladinbaarcheologist") and HasScript(this, "paladinbaarcheologistdesc"))) {
        do (this, "paladinbaarcheologistdesc")
      }
      else if ((GetBoolean(player, "Baarcheologistapologist") and HasScript(this, "baarcheologistapologistdesc"))) {
        do (this, "baarcheologistapologistdesc")
      }
      else if ((GetBoolean(player, "Philanthropistbaarcheologist") and HasScript(this, "philanthropistbaarcheologistdesc"))) {
        do (this, "philanthropistbaarcheologistdesc")
      }
      else if ((GetBoolean(player, "Baarcheologistdisciple") and HasScript(this, "baarcheologistdiscipledesc"))) {
        do (this, "baarcheologistdiscipledesc")
      }
      else if ((GetBoolean(player, "Baarcheologistpilgrim") and HasScript(this, "baarcheologistpilgrimdesc"))) {
        do (this, "baarcheologistpilgrimdesc")
      }
      else if (HasScript(this, "baarcheologistdesc")) {
        do (this, "baarcheologistdesc")
      }
      else if (HasScript(this, "collectdesc")) {
        do (this, "collectdesc")
      }
      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, "Archanist") and HasScript(this, "archanistdesc"))) {
      do (this, "archanistdesc")
    }
    else if ((GetBoolean(player, "Hunter") and HasScript(this, "hunterdesc"))) {
      do (this, "hunterdesc")
    }
    else if ((GetBoolean(player, "Assassin") and HasScript(this, "assassindesc"))) {
      do (this, "assassindesc")
    }
    else if ((GetBoolean(player, "Thief") and HasScript(this, "thiefdesc"))) {
      do (this, "thiefdesc")
    }
    else if ((GetBoolean(player, "Barcheologist") and HasScript(this, "barcheologistdesc"))) {
      do (this, "barcheologistdesc")
    }
    else if ((GetBoolean(player, "Gothicist") and HasScript(this, "gothicistdesc"))) {
      do (this, "gothicistdesc")
    }
    else if ((GetBoolean(player, "Finder") and HasScript(this, "finderdesc"))) {
      do (this, "finderdesc")
    }
    else if ((GetBoolean(player, "Treasurehunter") and HasScript(this, "treasurehunterdesc"))) {
      do (this, "treasurehunterdesc")
    }
    else if (HasScript(this, "collectdesc")) {
      do (this, "collectdesc")
    }
    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.}")
    }
  }
  case ((player.Ninja)) {
    if (GetBoolean(player, "Pantherninja")) {
      if ((GetBoolean(player, "Pantherillusionist") and HasScript(this, "pantherillusionistdesc"))) {
        do (this, "pantherillusionistdesc")
      }
      else if ((GetBoolean(player, "Pantherassassin") and HasScript(this, "pantherassassindesc"))) {
        do (this, "pantherassassindesc")
      }
      else if ((GetBoolean(player, "Pantherburglar") and HasScript(this, "pantherburglardesc"))) {
        do (this, "pantherburglardesc")
      }
      else if ((GetBoolean(player, "Pantherjesuit") and HasScript(this, "pantherjesuitdesc"))) {
        do (this, "pantherjesuitdesc")
      }
      else if ((GetBoolean(player, "Shadowpanther") and HasScript(this, "shadowpantherdesc"))) {
        do (this, "shadowpantherdesc")
      }
      else if ((GetBoolean(player, "Spypanther") and HasScript(this, "spypantherdesc"))) {
        do (this, "spypantherdesc")
      }
      else if (HasScript(this, "pantherninjadesc")) {
        do (this, "pantherninjadesc")
      }
      else if (HasAttribute(this, "ninjadesc")) {
        do (this, "ninjadesc")
      }
      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, "Voyeur")) {
      if ((GetBoolean(player, "Illusionistvoyeur") and HasScript(this, "illusionistvoyeurdesc"))) {
        do (this, "illusionistvoyeurdesc")
      }
      else if ((GetBoolean(player, "Voyeurbib") and HasScript(this, "voyeurbibdesc"))) {
        do (this, "voyeurbibdesc")
      }
      else if ((GetBoolean(player, "Shadowsnmvoyeur") and HasScript(this, "shadowsnmvoyeurdesc"))) {
        do (this, "shadowsnmvoyeurdesc")
      }
      else if ((GetBoolean(player, "Privateeye") and HasScript(this, "privateeyedesc"))) {
        do (this, "privateeyedesc")
      }
      else if (HasScript(this, "voyeurdesc")) {
        do (this, "voyeurdesc")
      }
      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, "Illusionist") and HasScript(this, "illusionistdesc"))) {
      do (this, "illusionistdesc")
    }
    else if ((GetBoolean(player, "Assassin") and HasScript(this, "assassindesc"))) {
      do (this, "assassindesc")
    }
    else if ((GetBoolean(player, "Thief") and HasScript(this, "thiefdesc"))) {
      do (this, "thiefdesc")
    }
    else if ((GetBoolean(player, "Jesuit") and HasScript(this, "jesuitdesc"))) {
      do (this, "jesuitdesc")
    }
    else if ((GetBoolean(player, "Shadow") and HasScript(this, "shadowdesc"))) {
      do (this, "shadowdesc")
    }
    else if ((GetBoolean(player, "Spy") and HasScript(this, "spydesc"))) {
      do (this, "spydesc")
    }
    else if (HasScript(this, "ninjadesc")) {
      do (this, "ninjadesc")
    }
    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.}")
    }
  }
  default {
    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.}")
  }
}

Maybe we can fix it, maybe not. But I'll trust your advice either way and go back to the if tree. I somehow thought I was saving the computer from thinking because it could skip any branch for which there was no match.


Is it the same error?
No line, code, or character quoted in the error message?


Yeah, that's it. Just "Object reference not set to an instance of an object."

Frustratingly vague haha

I did complete the entire thing as an "if" tree which is now my "classperspecitves" function, and it works. (fixed some typos and filled in some missing defaults pictured above during my testing phase).

Just a little sad that my first attempt at a switch script failed haha.


Mrangel!

I re-read what you said with fresh eyes and some sleep! I get it now!

So switches need constants as their "case" input so they can build!

I don't know why I thought you were saying Switches need the output to be the same thing in every case before. SMH. I'm going to try and blame sleep depravation. I've been sleeping something like 3-5 hours a night since I discovered Quest, because I get so engrossed I just stay up!

Maybe the issue with this switch, then, is that the player wasn't flagged with all of those variables (obviously) when I was trying to test it. It didn't know how to skip cases where the variable didn't actually exist?

Well anyway, now I understand something about switches a little better which I hadn't before. I like the flipping for headings vs building an index metaphor. It does help when the reader isn't half delirious!


Maybe the issue with this switch, then, is that the player wasn't flagged with all of those variables (obviously) when I was trying to test it. It didn't know how to skip cases where the variable didn't actually exist?

If the variables are all true or false, it should work fine. If some of them are undefined, I think you'll have an error. For some reason, case doesn't like its arguments being null.


Ok, so it would work, if we added the attributes ahead of time, and made them false. But the attributes are added during character generation and game choices and interactions, so were undefined in some cases as I tested.

Which now makes more sense about wanting to be fixed things for the cases... hmmm.

Thanks for these insights. The player perspectives and classes are things which can be indexed in a way... even though the individual player doesn't have all of them.

I have to say again that I'm thoroughly enjoying learning to make games and code from scratch, and very grateful that you're here helping us mrangel!


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

Support

Forums