GetIsItemPropertyValid
From NWN Lexicon
Jump to navigationJump to search
GetIsItemPropertyValid(itemproperty)
Checks if an itemproperty is valid.
Parameters
ipProperty
Itemproperty to check whether is valid or not.
Description
If the item property is valid this will return true.
Remarks
Returns TRUE if ipProperty is a valid itemproperty, FALSE if it isn't.
Basically, it does with an itemproperty what GetIsObjectValid does for objects and GetIsEffectValid does for effects.
The most obvious use for this function is as a check to exit a loop of an item's properties.
Version
1.61
Example
//Remove true seeing from the entering PC's headgear
void main()
{
//Entering object
object oPC=GetEnteringObject();
//Only PCs
if (!GetIsPC(oPC)) return;
//That PC's helmet
object oItem=GetItemInSlot(INVENTORY_SLOT_HEAD, oPC);
//Stop script if the PC had no helmet on
if (!GetIsObjectValid(oItem)) return;
//Get the first itemproperty on the helmet
itemproperty ipLoop=GetFirstItemProperty(oItem);
//Loop for as long as the ipLoop variable is valid
while (GetIsItemPropertyValid(ipLoop))
{
//If ipLoop is a true seeing property, remove it
if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_TRUE_SEEING)
RemoveItemProperty(oItem, ipLoop);
//Next itemproperty on the list...
ipLoop=GetNextItemProperty(oItem);
}
}
void main()
{
//Entering object
object oPC=GetEnteringObject();
//Only PCs
if (!GetIsPC(oPC)) return;
//That PC's helmet
object oItem=GetItemInSlot(INVENTORY_SLOT_HEAD, oPC);
//Stop script if the PC had no helmet on
if (!GetIsObjectValid(oItem)) return;
//Get the first itemproperty on the helmet
itemproperty ipLoop=GetFirstItemProperty(oItem);
//Loop for as long as the ipLoop variable is valid
while (GetIsItemPropertyValid(ipLoop))
{
//If ipLoop is a true seeing property, remove it
if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_TRUE_SEEING)
RemoveItemProperty(oItem, ipLoop);
//Next itemproperty on the list...
ipLoop=GetNextItemProperty(oItem);
}
}
See Also
functions: |
author: Lilac Soul