Attribute number help

yes ive posted about the same thing before, but this should be the last issue .

I have player charatcer with attribute Skills at value 3 to start
i then have (under npc's speak to options)

switch (Kurota.Skills) {
  case (3) {
    PrintCentered ("Dash & Slash {Blade} S dammade all enemies")
  }
  case (4) {
    PrintCentered ("Breeze [Gust] S dammage all enemies")
  }

However, it just results in this error:
"Error running script: Object reference not set to an instance of an object."


I copied that code (with the closing }) into a new game, and it works fine.
Are you sure this is where the error is being generated?


Edit: It looks like `switch` doesn't handle `null` properly. I wasn't aware of this. It took me a while to figure out, because that error message isn't in any of the Quest code.

switch internally casts its parameters to strings before comparing them (why?), and the message is generated whenever you attempt to cast null.

That's not really helpful; but I would call that a bug in Quest rather than your code.

Are you sure that Kurota's Skills attribute is set to 3? The only way I can get that error to appear in that code is if the attribute is set to null (or isn't set, which is the same thing).


@mr.angel its definately set to 3 under attributes
can link to a screenshot


Io

Is it possible Skills is a string value of "3" as opposed to the number 3?


@Io That's one of the things I tried; it still matches.
switch and case convert their arguments to strings before comparing.


No idea what the issue is.....


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

Support

Forums