Difference between revisions of "AddItem"

From GECK

(using HTML unordered list to include the code sample in the list)
(Use function template. Move bug into specific bugs section. Reword examples.)
Line 1: Line 1:
=='''Description'''==
+
{{Function
 
+
|origin = GECK1
'''AddItem''' Adds Count items of object ObjectID to the calling container's inventory.  It has two required parameters (the object to add and the quantity) and one optional parameter (whether to display a message on screen).
+
|summary = Adds Count items of object ObjectID to the calling container's inventory.  It has two required parameters (the object to add and the quantity) and one optional parameter (whether to display a message on screen).
 
+
|referenceType = <nowiki>ActorID|ContainerID</nowiki>
=='''Syntax'''==
+
|arguments = {{FunctionArgument
 
+
    |Name = ObjectID
[''ActorID|ContainerID''.]AddItem ''ObjectID, Count, MessageHiddenFlag''
+
    |Type = ref
 
+
  }}{{FunctionArgument
=='''Examples'''==
+
    |Name = Count
 
+
    |Type = int
 +
  }}{{FunctionArgument
 +
    |Name = HideMessageFlag
 +
    |Type = int
 +
    |Optional = y
 +
  }}
 +
}}
 +
==Examples==
 
  buddyref.additem Stimpack 11
 
  buddyref.additem Stimpack 11
Buddy now has 11 stimpacks
+
Adds 11 stimpacks to Buddy's inventory
 
  player.additem SuperStimpak 10
 
  player.additem SuperStimpak 10
The player now has 10 super stimpacks and message displays like normal
+
Adds 10 super stimpacks to the player's inventory and the message displays like normal
 
  player.additem SuperStimpak 10 1
 
  player.additem SuperStimpak 10 1
The player now has 10 super stimpacks and no message would be displayed when these items are added
+
Adds 10 super stimpacks to the player's inventory and no message is displayed
  
=='''Notes'''==
+
==Notes==
 +
*You can use a FormList as the item parameter - in this case, the function adds the count for each item in the list.
  
<ul><li>You can use a FormList as the item parameter - in this case, the function adds the count for each item in the list.</li>
+
==Bugs==
<li>Calling [[AddItem]] in an Effect Script will cause the target Actor's Weapon to toggle between being visible and usable and being invisible and unusable. To fix this, use something like this in the script of the item that is being added:
+
<ul><li>Calling [[AddItem]] in an Effect Script will cause the target actor's weapon to toggle between being visible and usable and being invisible and unusable. The cause of this bug is unknown, but as a workaround, use something like this in the script of the item that is being added:
 
<pre>ref rContainer
 
<pre>ref rContainer
 
Begin OnAdd
 
Begin OnAdd
Line 27: Line 35:
 
End</pre></li></ul>
 
End</pre></li></ul>
  
=='''See Also'''==
+
==See Also==
[[RemoveItem]]<br>
+
*[[RemoveItem]]
[[AddItemHealthPercent]]<!--
+
*[[AddItemHealthPercent]]
 
+
Why is this even here? -- ~~~~
+
=='''Reference'''==
+
None provided.
+
[[AddItem_Reference|List of functions that use AddItem]]  (wiki) -->
+
  
 
[[Category:Functions]]
 
[[Category:Functions]]

Revision as of 13:11, 10 February 2009

A function included in the GECK version 1.1.0.36.

Description

Adds Count items of object ObjectID to the calling container's inventory. It has two required parameters (the object to add and the quantity) and one optional parameter (whether to display a message on screen).

Syntax

ActorID|ContainerID.AddItem ObjectID:ref Count:int HideMessageFlag:int

Examples

buddyref.additem Stimpack 11

Adds 11 stimpacks to Buddy's inventory

player.additem SuperStimpak 10

Adds 10 super stimpacks to the player's inventory and the message displays like normal

player.additem SuperStimpak 10 1

Adds 10 super stimpacks to the player's inventory and no message is displayed

Notes

  • You can use a FormList as the item parameter - in this case, the function adds the count for each item in the list.

Bugs

  • Calling AddItem in an Effect Script will cause the target actor's weapon to toggle between being visible and usable and being invisible and unusable. The cause of this bug is unknown, but as a workaround, use something like this in the script of the item that is being added:
    ref rContainer
    Begin OnAdd
    	set rContainer to GetContainer
    	rContainer.AddItem Pencil01 1 1
    	rContainer.RemoveItem Pencil01 1 1
    End

See Also

Personal tools