Difference between revisions of "GetModuleItemLostBy"

From NWN Lexicon
Jump to: navigation, search
m (Wikified article formatting)
 
Line 1: Line 1:
=GetModuleItemLostBy()=
+
Get the creature that lost the item on an OnUnAcquireItem event.
 
 
Get the creature that lost the item on an OnUnAcquiredItem event.
 
  
 
<nwscript>
 
<nwscript>
Line 7: Line 5:
 
</nwscript>
 
</nwscript>
  
====Description====
+
===Description===
 
+
Returns the object that dropped an item triggering the [[OnUnAcquireItem]] event. On error this function will return OBJECT_INVALID; this should not be possible as the event is triggered by an item drop, but if you trigger the event manually then be aware of this error.
Returns the object that dropped an item triggering the OnUnAcquiredItem event. On error this function will return OBJECT_INVALID; this should not be possible as the event is triggered by an item drop, but if you trigger the event manually then be aware of this error.
 
 
 
<br /><br />
 
 
 
====Remarks====
 
 
 
We know that the OnUnacquireItem fires for objects destroyed by <br /> DestroyObject, right? Well, the object returned by this function is not <br /> OBJECT_INVALID in this case, but it is also not an existing object so any <br /> usage of it does not function correctly. Instead of checking for <br /> OBJECT_INVALID, the users of this function should always use <br /> GetIsObjectValid, which returns FALSE for the case mentioned above. <br />
 
 
 
<br />
 
  
====Version====
+
===Remarks===
 +
We know that the OnUnAcquireItem fires for objects destroyed by DestroyObject, right? Well, the object returned by this function is not OBJECT_INVALID in this case, but it is also not an existing object so any usage of it does not function correctly. Instead of checking for OBJECT_INVALID, the users of this function should always use [[GetIsObjectValid]](), which returns FALSE for the case mentioned above.
  
 +
===Version===
 
1.28
 
1.28
  
====Example====
+
===Example===
 
 
 
<nwscript>
 
<nwscript>
 
// This will find the name of the creature the item was dropped by.
 
// This will find the name of the creature the item was dropped by.
Line 30: Line 20:
 
{
 
{
 
     object a = GetModuleItemLost();
 
     object a = GetModuleItemLost();
     if(a == OBJECT_INVALID)
+
     if (a == OBJECT_INVALID)
 
         SendMessageToPC(GetFirstPC(),"OOPS A CRASH ME THINKS");
 
         SendMessageToPC(GetFirstPC(),"OOPS A CRASH ME THINKS");
     else {
+
     else
 +
    {
 
         SendMessageToPC(GetFirstPC(),GetTag(a));
 
         SendMessageToPC(GetFirstPC(),GetTag(a));
 
         a = GetModuleItemLostBy();
 
         a = GetModuleItemLostBy();
         if(a == OBJECT_INVALID)
+
         if (a == OBJECT_INVALID)
 
             SendMessageToPC(GetFirstPC(),"OOPS A CRASH ME THINKS");
 
             SendMessageToPC(GetFirstPC(),"OOPS A CRASH ME THINKS");
 
         else
 
         else
 
             SendMessageToPC(GetFirstPC(),"And was dropped by " + GetTag(a));
 
             SendMessageToPC(GetFirstPC(),"And was dropped by " + GetTag(a));
        }
+
    }
 
}
 
}
 
 
</nwscript>
 
</nwscript>
  
====See Also====
+
===See Also===
  
 
{| class="seealso"
 
{| class="seealso"
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
|
+
| [[GetModuleItemLost]], [[GetModuleItemAcquiredFrom]]
[[ GetModuleItemLost  | GetModuleItemLost ]]
 
|-
 
 
|-
 
|-
 
| width="1px" align="right" valign="top" | <font color="gray">events: </font>
 
| width="1px" align="right" valign="top" | <font color="gray">events: </font>
|
+
| [[OnUnAcquireItem|OnUnAcquireItem Event]]
[[ OnUnAcquireItem | OnUnAcquireItem Event ]]
+
|} <br />
|}
 
 
 
<br />
 
 
----
 
----
<font color="gray">  author: GoLeM, editor: Charles Feduke, additional contributor(s): Charles Mead, Timothy Dang, Matthew Green, David Kondrad</font><br />  <br />
+
<font color="gray">  author: GoLeM, editor: Charles Feduke, additional contributor(s): Charles Mead, Timothy Dang, Matthew Green, David Kondrad</font>
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:Inventory_Functions]]
 
[[Category:Inventory_Functions]]
[[Category:Module_Functions]]
+
[[Category:Module_Functions]]{{DISPLAYTITLE:GetModuleItemLostBy()}}

Latest revision as of 01:47, 18 February 2018

Get the creature that lost the item on an OnUnAcquireItem event.

Description

Returns the object that dropped an item triggering the OnUnAcquireItem event. On error this function will return OBJECT_INVALID; this should not be possible as the event is triggered by an item drop, but if you trigger the event manually then be aware of this error.

Remarks

We know that the OnUnAcquireItem fires for objects destroyed by DestroyObject, right? Well, the object returned by this function is not OBJECT_INVALID in this case, but it is also not an existing object so any usage of it does not function correctly. Instead of checking for OBJECT_INVALID, the users of this function should always use GetIsObjectValid(), which returns FALSE for the case mentioned above.

Version

1.28

Example

// This will find the name of the creature the item was dropped by.
void main()
{
    object a = GetModuleItemLost();
    if (a == OBJECT_INVALID)
        SendMessageToPC(GetFirstPC(),"OOPS A CRASH ME THINKS");
    else
    {
        SendMessageToPC(GetFirstPC(),GetTag(a));
        a = GetModuleItemLostBy();
        if (a == OBJECT_INVALID)
            SendMessageToPC(GetFirstPC(),"OOPS A CRASH ME THINKS");
        else
            SendMessageToPC(GetFirstPC(),"And was dropped by " + GetTag(a));
    }
}

See Also

functions:  GetModuleItemLost, GetModuleItemAcquiredFrom
events:  OnUnAcquireItem Event


 author: GoLeM, editor: Charles Feduke, additional contributor(s): Charles Mead, Timothy Dang, Matthew Green, David Kondrad