Attribute number help

CheshireTiger
06 Jan 2020, 19:08

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."


mrangel
06 Jan 2020, 21:00

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).


CheshireTiger
06 Jan 2020, 21:15

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


Io
07 Jan 2020, 01:45

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


mrangel
07 Jan 2020, 09:12

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


CheshireTiger
08 Jan 2020, 18:43

No idea what the issue is.....