lordofworms wrote...
instead of
const string BONES = "wrm_bones";
like so:
const string BONES = "wrm_bones" || "wrm_skull" || "wrm_femur"
?
it doesnt compile and I couldnt find any info on whether its possible at all?
Thanks!!
Ahh, I already typed this one just to have it lost when the forums logged me out. So I am going to cover it a little faster this time.
I see serveral misconceptions in your statement. First is the Logical OR Operator. ( || ).
The Logical OR Operator Eveulates two Numbers as being either TRUE or FALSE to a TRUE or FALSE result per the logical truth table. It has no Idea on how to operate on strings.
If it could evelulate out it would set the result to the BONES lable equal to the single stinng of the evulation. Since the || operator eveulates out to a number again you have a type missmatch trying to place it into a string data type.
constants:
Constants are a Compile Time Varaiable. They are never placed into the compiled code as a Labled Constant. Anyplace the constant is used in the script, the compiler replaces it with the value of the constant before the script is converted into compiled code.
The compiler is stupid;
The compiler does not know how to eveulate expressions. Where a statment like:
const int MyCONST = 20/5;
would be legal in most languages with 20/5 eveulating out to 4 and having all uses of MYCONST being replaced by 4 in the script at compile time. The nwscript compiler simply does not know how to divide. Or how to eveulate any of the Mathmatical or logical Operations for that matter.
I hope this shorter post of the original is helpfull, If not feel free to ask questions.
As far as what you are trying to do. It looks like just placing everything into one string would give you something to check against. Also a constant is probably not the best choice in this case, the reason is that the constant when used is replaced with the string. If you used a varaiable instead of the constant, everything would be checked against the one string var instead of reproducing that constant for every use in the script.
int GetIsBones(string sTag)
{
//note: that I left a space at the begining and end of the string.
string BONES = " wrm_bones wrm_skull wrm_femur " ;
sTag = " "+sTag+" ";
return FindSubString(BONES,sTag) != -1;
}