Is their an OR operator in NWN scripting? I haven't been able to find anything in the lexicon.
example..
if (GetTag(oItem) != "item1" OR "item2")
{
DestroyObject(oItem);
}
OR operator ?
Débuté par
Buddywarrior
, févr. 27 2011 03:43
#1
Posté 27 février 2011 - 03:43
#2
Posté 27 février 2011 - 03:49
Yes. It's done as "||".
string sTag = GetTag(oItem); /* I do this here to avoid redundant calls to get the item's tag. */
if (sTag != "item1" || sTag != "item2")
{
DestroyObject(oItem);
}
So...if the tag does not equal "item1", destroy the item.
or it the tag does not equal "item2", destroy the item.
Looks like the item is getting destroyed no matter what.
-------------------------------------
There is also a version of AND. It's done as "&&". And it sounds closer to what it looks like you want in your code snippet, since both conditions need to be met for the item to be destroyed, rather than just one of them.
string sTag = GetTag(oItem); /* I do this here to avoid redundant calls to get the item's tag. */
if (sTag != "item1" && sTag != "item2")
{
DestroyObject(oItem);
}
If the tag does not equal "item1" and the tag does not equal "item2", then destroy the item.
string sTag = GetTag(oItem); /* I do this here to avoid redundant calls to get the item's tag. */
if (sTag != "item1" || sTag != "item2")
{
DestroyObject(oItem);
}
So...if the tag does not equal "item1", destroy the item.
or it the tag does not equal "item2", destroy the item.
Looks like the item is getting destroyed no matter what.
-------------------------------------
There is also a version of AND. It's done as "&&". And it sounds closer to what it looks like you want in your code snippet, since both conditions need to be met for the item to be destroyed, rather than just one of them.
string sTag = GetTag(oItem); /* I do this here to avoid redundant calls to get the item's tag. */
if (sTag != "item1" && sTag != "item2")
{
DestroyObject(oItem);
}
If the tag does not equal "item1" and the tag does not equal "item2", then destroy the item.
Modifié par The Amethyst Dragon, 27 février 2011 - 03:58 .
#3
Posté 27 février 2011 - 03:52
I think this will help... not tested though.
if (GetTag(oItem) != "item1" || GetTag(oItem) !="item2")
And "AD" beats me to the punch ..
if (GetTag(oItem) != "item1" || GetTag(oItem) !="item2")
And "AD" beats me to the punch ..
Modifié par kalbaern, 27 février 2011 - 03:53 .
#4
Posté 27 février 2011 - 04:30
Thanks guys. I knew their had to be something to handle the OR.
#5
Posté 27 février 2011 - 04:31
(doublepost) .
Modifié par Buddywarrior, 27 février 2011 - 04:31 .
#6
Posté 27 février 2011 - 05:12





Retour en haut






