-
Notifications
You must be signed in to change notification settings - Fork 2
DataPointer
The DataPointer is used to reference other records. It is resolved during loading and allows for the target record to be overridden by other plugins while maintaining the reference.
It is possible to serialize a data pointer in your own save file with Protocol Buffers or Json.NET and set the deserialization database before deserializing to resolve the pointers.
Papyrus.DataPointer.SetDeserializationDatabase(recordDatabase);
// Deserialize your save file, all DataPointers will be correctly resolved.
// DataPointerExceptions will be thrown for any unresolved pointers
Papyrus.DataPointer.SetDeserializationDatabase(null);| Description | |
|---|---|
| Source | Name of the plugin the referenced record is located in. |
| Plugin | Name of the plugin that the references record was located in when saved. This can differ from Source if the reference is to a record which has been overridden by another plugin. Details here |
| IsEmpty | True if the record has no value. This differs from IsValid in that it is only true if the pointer was never set to a value (null). |
| IsValid | It is possible for a DataPointer to be invalid. This value can be false if the referenced record hasn't been resolved, or if it was never set in the first place. If a pointer IsEmpty, it will not be valid. If the plugin which this pointers record was contained in is not loaded, it will not be valid. |
Papyrus was designed with modding in mind from the start. As a result, records can be overridden by records from other plugins. DataPointers can also reference a record which overrode a record in a different plugin (wat). The Plugin member provides a means of determining if the exact record this pointer referenced is available.
For example, Plugin A contains a single record.
| Plugin A | ||
|---|---|---|
| Location | Destination | |
| Record 0 | Plugin A | Plugin A |
Plugin B overrides this record with it's own Record 0.
| Plugin B | ||
|---|---|---|
| Location | Destination | |
| Record 0 | Plugin B | Plugin A |
Plugin C might have a data pointer to Record 0.
| Plugin C | ||
|---|---|---|
| DataPointer | Source | Plugin |
| Record 0 | Plugin A | Plugin B |
In this case, the DataPointer in Plugin C is referencing Record 0, which was initially created in Plugin A. However, Plugin B was also loaded while Plugin C was being created. This could potentially lead to problems if Plugin B was no longer present when Plugin C is loaded. Plugin C could be said to be dependent on Plugin B.
Internally Papyrus uses the Plugin field to determine what other plugins a plugin is dependent on.