Difference between revisions of "AddItem"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Vvenaya
(<Draft 1b>)
imported>Shademe
(→‎Console Usage: Moved some text to the discussion page)
 
(34 intermediate revisions by 13 users not shown)
Line 1: Line 1:
=='''Description'''==
__NOTOC__


Adds Count items of object ObjectID to the calling container's inventory.
'''Syntax:'''
[''ActorID''|''ContainerID''.]AddItem ''ObjectID'', ''Count''


=='''Syntax'''==
Adds ''Count'' items of object ''ObjectID'' to the calling container's inventory.
AddItem ''ObjectID'', ''Count''  


=='''Example'''==
'''Examples:'''
  AddItem MyObject, 1  
  AddItem MyObject, 1


=='''Comments'''==
Ref MyItem
Short count
set MyItem to ArenaAkaviriLongSword
set count to 1
player.additem MyItem Count


==Notes==
* You can use a [[Variable_types:_reference_variables|reference variable]] as ''ObjectID'' and a [[Variable_types:_shortint|short]] variable for ''count''.
* This function will trigger an [[onAdd]] block in a script attached to the target container, as long as the container is in a loaded cell. When used on a container in a remote cell, the [[onAdd]] block won't run until the player enters that container's cell. However, if the player enters the remote cell after saving and loading, the onAdd block won't run.
** Note that this is only true for the onAdd block, the rest of the script will still run if applicable (GameMode block will run if it's GameMode, MenuMode if MenuMode, etc.). The script will run once, as if it were loaded. If you have any variables set on the script, it will run the next frame as well and will continue to run until no variables are set.
* See [[Message Spam]] for techniques to avoid unwanted "Item Added" messages.


NOTE: This will not trigger [[OnAdd]] blocks, because the item is created inside the inventory rather than actually being added. For creating items from the console that you need to trigger OnAdd, use [[PlaceAtMe]] instead and pick the item up from the ground.
==Console Usage==
 
When using AddItem with the console, you must use the desired item's FormID, not the EditorID.
----
 
Console UsageWhen using AddItem with the console, you must use the desired item's FormID, not the EditorID.


So, instead of using
So, instead of using
Line 24: Line 31:
  player.additem 00000A 1
  player.additem 00000A 1


Kedrigh wrote: [http://www.elderscrolls.com/forums/index.php?showtopic=323641&hl=#]
==See Also==
*[[AddItemNS]] - Spamless version of command (OBSE 15).
*[[GetItemCount]]
*[[RemoveItem]]
*[[Message Spam]] - Techniques for avoiding message spam.


''Form id is in the cs and looks like this: yyxxxxxx.''
==Reference==


''yy is used to reference the plugin, xxxxxx to reference the item inside the plugin (and does not change). So if you load the oblivion master in the cs, and create something, it will have 01xxxxxx as the form id.''
[[AddItem_Reference|List of existing scripts that use AddItem]]


''The yy part of the formid changes depending on the mods you load up, in alphabetical order (first one 01, second 02, and so on.)
[[Category: Functions]]
''
[[Category:Functions (CS)]]
 
[[Category: Functions (CS 1.0)]]
=='''Script Usage'''==
[[Category: Inventory Functions]]
{| cellpadding="5" cellspacing="0" width="100%"
[[Category: Inventory Functions (CS 1.0)]]
|-
[[Category: Actor Functions]]
| style="background:#ffeded;border-bottom:1px solid;"  width="30%"  |
[[Category: Actor Functions (CS 1.0)]]
 
AlessiaCaroScript
 
AncontarScript
 
BagduGroMolobscript
 
ClaudeMaricScript
 
DAAzuraStatueScript
 
DABoethiaStatueScript


DAClavicusStatueScript
<!-- Begin Search Terms
 
Add
DAHermaeusStatueScript
Item
 
End Search Terms -->
DAHircineStatueScript
 
DairihillsDeskScript
 
DAMalacathStatueScript
 
DAMephalaStatueScript
 
DAMeridiaStatueScript
 
DAMolagBalStatueScript
 
DANamiraPriestScript
 
DANamiraScript
 
DANamiraStatueScript
 
DANocturnalStatueScript
 
DAPeryiteStatueScript
 
Dark09PhillidaBodyguardScript
 
Dark10SpecialDeadDropScript
 
Dark11DeadDropScript
 
Dark13DeadDropScript
 
Dark14DeadDropScript
 
Dark17FollowingScript
 
DASanguineStatueScript
 
| style="background:#ffeded;border-bottom:1px solid;"  width="30%"  |
 
DASheogorathStatueScript
 
DAVaerminaStatueScript
 
FGPostQuest
 
GrayFoxScript
 
GwinasScript
 
HannibalTravenScript
 
HouseSkingradQuestHGScript
 
IverScript
 
MereteScript
 
MethredhelsChestScript
 
MethredhelScript
 
MG04Script
 
MG05AScript
 
MG08CupboardScript
 
MG08Script
 
MG09Script
 
MG15IrlavJarolDeadScript
 
MG16MageScript
 
MG17Script
 
MG19ChestScript
 
MQ10SigilStoneActivatorScript
 
MQ10SigilStoneScript
 
MQ12GoblinInventorySCRIPT
 
MQ12UndeadInventorySCRIPT
 
MQ13Script
 
MQ14SigilStoneScript
 
 
| style="background:#ffeded;border-bottom:1px solid;"  width="30%"  |
 
MQ15KathutetSCRIPT
 
MS05DreamworldAmuletScript
 
MS05DreamworldElementActivators01
 
MS05DreamworldElementActivators02
 
MS05DreamworldElementActivators03
 
MS05DreamworldElementActivators04
 
MS08AleronLocheScript
 
MS08FakeDoorKeyScript
 
MS13SigilScript
 
MS45DarMaChestScript
 
MS46RewardChestSCRIPT
 
MS48SigilStoneScript
 
MSScarTailScript
 
MyvrynasCupboardScript
 
NecroAltarScript
 
NecroAnchoriteDFScript
 
OghashgraMagulSCRIPT
 
OntusVaninsChestScript
 
OrumGangCourier1SCRIPT
 
SiegeCrawlerDeathSCRIPT
 
SigilStoneRandomSCRIPT
 
SigilStoneScript
 
TG05ScampScript
 
TG07LegionSealScript
 
TGIcestaffDisplayCaseScript
 
UmbacanoScript
 
|}
 
 
 
[[Category: Functions]]
[[Category: Object Functions]]

Latest revision as of 18:40, 28 March 2010


Syntax:

[ActorID|ContainerID.]AddItem ObjectID, Count 

Adds Count items of object ObjectID to the calling container's inventory.

Examples:

AddItem MyObject, 1
Ref MyItem
Short count

set MyItem to ArenaAkaviriLongSword
set count to 1
player.additem MyItem Count

Notes[edit | edit source]

  • You can use a reference variable as ObjectID and a short variable for count.
  • This function will trigger an onAdd block in a script attached to the target container, as long as the container is in a loaded cell. When used on a container in a remote cell, the onAdd block won't run until the player enters that container's cell. However, if the player enters the remote cell after saving and loading, the onAdd block won't run.
    • Note that this is only true for the onAdd block, the rest of the script will still run if applicable (GameMode block will run if it's GameMode, MenuMode if MenuMode, etc.). The script will run once, as if it were loaded. If you have any variables set on the script, it will run the next frame as well and will continue to run until no variables are set.
  • See Message Spam for techniques to avoid unwanted "Item Added" messages.

Console Usage[edit | edit source]

When using AddItem with the console, you must use the desired item's FormID, not the EditorID.

So, instead of using

player.additem lockpick 1

to give yourself a lockpick, you must use

player.additem 00000A 1

See Also[edit | edit source]

Reference[edit | edit source]

List of existing scripts that use AddItem