Page 1 of 1

How to detect the player's race

PostPosted: Thu Nov 09, 2017 4:29 pm
by KGold
So I'm trying to apply the script 'getrace' in a code, but apparently I'm doing something wrong.

if(player.getrace("Etherim")) or if(player.getrace(base_etherim)) don't work, the error message says 'invalid number of arguments'. The tutorial doesn't specify this. What's the right way to use this script?

Re: How to detect the player's race

PostPosted: Fri Nov 10, 2017 8:31 am
by Catacomber
It's an ability--so you have to query it like any other ability--

base_abetherim

Re: How to detect the player's race

PostPosted: Fri Nov 10, 2017 1:26 pm
by Schicko
Catacomber wrote:It's an ability--so you have to query it like any other ability--

base_abetherim


I think that's for the hasability() function. Even then, I've tried the following as a rasvim and none of them output "you're rasvim":
Code: Select all
if (player.hasability("base_abrasvim")) {
   message("you're rasvim");
} else {
   message("you're not rasvim");
}

and also:
Code: Select all
if (player.getrace() = base_rasvim) {
   message("you're rasvim");
} else {
   message("you're not rasvim");
}


The second one above should also have worked (but also doesn't) because I tried:
Code: Select all
race = player.getrace();
message(race);

which resulted in the output:
Code: Select all
base_rasvim


I've also tried all possible permutations of the code snippets above with and without quotation marks delimiting abrasvim or rasvim. But still none of them worked.

The closest thing I could get the getrace() to produce a response is with:
Code: Select all
race = player.getrace();
if (race = base_rasvim) {
   message("you're rasvim");
} else {
   message("you're not rasvim");
}

which resulted in a runtime error stating:
Code: Select all
The Quest Editor v1.0: Error in c:\home\development\projects\Quest\Quest1\source\Quest/Core/PointerArray.h at line 345.

Please see: redshift.hu/help

when the dialogue containing that script is selected.

Other than that, the only way to be able to use player's race in dialogue that actually works seems to be possible only by using the PCRace or PCUndead dialogue conditions or with the isundead() function (the latter two of which only differentiates between rasvim and non rasvim, and not with other races). The isundead() function works properly when used like so:
Code: Select all
if (player.isundead()) {
   message("you're rasvim");
} else {
   message("you're not rasvim");
}


To conclude, it seems like hasability() and getrace() functions in the script editor/compiler are broken when used to try and match statements with player's race.

Re: How to detect the player's race

PostPosted: Fri Nov 10, 2017 2:38 pm
by KGold
Should've thought of this. I remember checking the 'Abilities' tab in the game and seeing my race there... :)

Seems like the purpose of the 'getrace' script is to display the race of the player, not detect it.
I'm aware of the use of the 'isundead' script, but in this case, I need something more specific.

Thank you for the help Cat and Schicko!