Update Object variable via OnEnter Trigger

Working on a portal system that requires a un-droppable custom item in the PC inventory tagged worldstoneshard

I ultimatly want the item’s local variable ‘bwwp’ added/updated to 1 after entering a trigger.

I’ve placed a trigger around the portal locations.

This is what I got from the script gen tool I use often. But I think it’s pointing at the PC and not the Object.

string sDeny;
/*   Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.com/View.php?view=Other.Detail&id=4683&id=625    */

//Put this script OnEnter
void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

if (GetItemPossessedBy(oPC, "worldstoneshard")== OBJECT_INVALID)
   {
   sDeny="you are missing something";

   SendMessageToPC(oPC, sDeny);

   return;
   }

SetLocalObject(oPC, "bwwp", 1);

}
void main()
{
    object oPC;
    object oItem;

    oPC = GetEnteringObject();

    if(!GetIsPC(oPC))
    {
        return;
    }

    oItem = GetItemPossessedBy(oPC, "worldstoneshard");

    if(GetIsObjectValid(oItem))
    {
        SetLocalInt(oItem, "bwwp", 1);
    }
    else
    {
        SendMessageToPC(oPC, "You are missing something.");
    }
}
1 Like