Difference between revisions of "PlaceAtMe"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Fella
imported>DragoonWraith
Line 16: Line 16:
It can't be used with leveled ''items'', though. Leveled items are not supposed to be placed into the world - you can use them exclusively inside containers. Trying to create an item from a leveled list this way will just cause the yellow exclamation mark (Marker_Error.NIF) to appear.
It can't be used with leveled ''items'', though. Leveled items are not supposed to be placed into the world - you can use them exclusively inside containers. Trying to create an item from a leveled list this way will just cause the yellow exclamation mark (Marker_Error.NIF) to appear.


==Warning : Disable does not Remove !==
==Warning: Repeated Use Causes Save-Game Bloat==


Note that it is really unclear at the moment whether or not disabled PlaceAtMe'd objects are ultimately cleaned out of the savegames. Tests seem to show they are not, which can be a serious problem with spells that create lots of activators, for instance, and then disable them.  
When PlaceAtMe creates a new reference to something, that reference is added to the savegame, and in most situations it cannot be removed. If PlaceAtMe is used in a script which can repeat an arbitrary number of times (i.e. every time the player does a specific action), the script will result in save game bloat.


So it seems only advisable to recommend the use of [[MoveTo]] on persistant references, whenever possible, instead of the couple [[PlaceAtMe]] / [[Disable]].
Save game bloat has been linked to extended load times, increasing game instability, and at extreme levels, considerable performance loss.
 
Therefore, avoid PlaceAtMe in any situation possible. Use [[MoveTo]] on persistant references instead of the [[PlaceAtMe]] / [[Disable]] couple.


Most of the time, MoveTo will prove at least as convenient as PlaceAtMe. However, if really ''need'' to use PlaceAtMe in your mod, it would be fair to indicate that fact in your mod's Readme file.
Most of the time, MoveTo will prove at least as convenient as PlaceAtMe. However, if really ''need'' to use PlaceAtMe in your mod, it would be fair to indicate that fact in your mod's Readme file.

Revision as of 07:23, 20 March 2008

Syntax:

PlaceAtMe ItemID, count, [distance], [direction] 

Example:

player.PlaceAtMe Ninja, 1, 256, 1 

Places the object at the calling object, in the direction you specify and the distance. If that location is not safe (in the air, in a wall, etc), the object will be placed at one of the other axes or at the object's exact location.

Direction is:

0 = front
1 = back
2 = left
3 = right

This function can be used with leveled creature lists as well.

It can't be used with leveled items, though. Leveled items are not supposed to be placed into the world - you can use them exclusively inside containers. Trying to create an item from a leveled list this way will just cause the yellow exclamation mark (Marker_Error.NIF) to appear.

Warning: Repeated Use Causes Save-Game Bloat

When PlaceAtMe creates a new reference to something, that reference is added to the savegame, and in most situations it cannot be removed. If PlaceAtMe is used in a script which can repeat an arbitrary number of times (i.e. every time the player does a specific action), the script will result in save game bloat.

Save game bloat has been linked to extended load times, increasing game instability, and at extreme levels, considerable performance loss.

Therefore, avoid PlaceAtMe in any situation possible. Use MoveTo on persistant references instead of the PlaceAtMe / Disable couple.

Most of the time, MoveTo will prove at least as convenient as PlaceAtMe. However, if really need to use PlaceAtMe in your mod, it would be fair to indicate that fact in your mod's Readme file.

Getting the Created Object's Reference

When used to create a single object, this function will return a reference to the created object so that it can be used with additional function calls.

Example:

scn scriptName

ref refName

begin blockName
     set refName to refCreatingObject.PlaceAtMe ObjectToBeCreated 1, 0, 0
end

The refName variable will now have a reference to ObjectToBeCreated.

This reference is only reliable for objects that can't be picked up. Accessing the reference of an inventory-item after someone picked it up can cause a CTD.

Usage in same frame as creation

If you use the referenced item in the same frame as you use PlaceAtMe, that is

set pItem to (player.PlaceAtMe IronBow 1, 0, 0)
pItem.Activate player ;this adds the bow to the player

that item's script may not run. Wait a frame, especially if using Activate.

Console Use

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

So, instead of using

player.PlaceAtMe lockpick 1, 256, 0

to give yourself a lockpick, you must use

player.PlaceAtMe 00000A 1, 256, 0

The FormID can be found on the tab just to the right of the EditorID tab in the Construction Set. This is true for all items and actors, although the FormID tab may need to be enlarged.