Talk:OnAdd

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

How does this work for stacked items? Does it run once for each item in the stack or once per stack?--Xilverbulet 23:43, 11 October 2007 (EDT)

-Looks like It runs for each item in the stack after testing.--Xilverbulet 00:04, 12 October 2007 (EDT)

Yes, they will each have their individual script. However, note that it can be very buggy if you add them at the same time.
--Haama 12:07, 12 October 2007 (EDT)

Some Test results[edit source]

Some observations from a series of tests on the OnAdd block with scripted Misc Items:

When picking up items from the world, when the OnActivate block runs, the OnAdd block does not run.
When the item is added to a remote container, the OnAdd block spontaneously runs after 5-60 seconds. It also runs if the remote container is activated (from anywhere)
This block did run in the following situations:
  • Player picks up an item in game and the item does not have an OnActivate block
  • Player opens a container and selects the item
  • Using Item.Activate xNPC01 0 - the OnActivate block does not run (flag=0), the OnAdd block runs
  • Added to containers by AddItem
  • Added to containers by RemoveAllItems [to container]
  • Added to containers by RemoveMe [to container]
This block did not run in the following situations:
  • the player picks up an item in game and the item has an OnActivate block
  • Using Item.Activate xNPC01 1 - the OnActivate block runs (flag=1), the OnAdd block does not run. If the script does not have an OnActivate block or the OnActivate block does not have an Activate function, the game freezes.

These results are part of a broader series of tests (see here). I thought they should also be reported here, to be confirmed/denied/discussed by the community. QQuix 22:05, 28 September 2008 (EDT)

RemoveMe[edit source]

Calling removeme in an onAdd block seems to result in a CTD.

The note's section in the removeMe article will shed some light. And please sign your post with a ~~~~. -- shademe 07:22, 7 January 2009 (EST)

How does this work in combination with GetSelf, GetContainer, GetActionRef[edit source]

In example:

Using GetContainer in an OnAdd block will return the container in which the object or the npc whom the object was added to (tested, it works)

Using GetSelf in an OnAdd is ignored (ie, does not change the value of the variable if already assigned).

This would be needed to all the Blocktypes in order to let ppl know how to obtain certain infos (in example I need to know the REF of the object I'm adding, and that seems impossible right now)

Elei-Mi-Shill 02:19, 2 August 2009

What you're trying to do is impossible. You can't put an item (inventory object) into a reference variable. An inventory object is just an item in a list, there may be many more identical items in the same container. These are all treated the same. To get one unique item you'll have to take it out of the container, then you put in a reference variable.
--Qazaaq 06:42, 2 August 2009 (EDT)