Difference between revisions of "Associating data with a reference"
Associating data with a reference (edit)
Revision as of 07:13, 5 September 2014
, 07:13, 5 September 2014new idea
imported>Odessa (expanded with dictionaries) |
imported>Odessa (new idea) |
||
Line 23: | Line 23: | ||
*You can use [[ToString|ToString($)]] to obtain the name of a reference as a string. However, all references with identical names will share the same key. | *You can use [[ToString|ToString($)]] to obtain the name of a reference as a string. However, all references with identical names will share the same key. | ||
*You can use [[GetFormIDString]] to return the unique form id as a string for any reference. However, form ids may change on game load with load order. Hence, if the data must be persistent some additional complex scripting is required. | *You can use [[GetFormIDString]] to return the unique form id as a string for any reference. However, form ids may change on game load with load order. Hence, if the data must be persistent some additional complex scripting is required. | ||
*You can use [[GetLocalRefIndex]] to obtain the numeric form id of a reference, without the load order prefix. However, using this alone will mean references from different mods may override each other. It is possible to workaround this by storing them in a nested array, using [[GetSourceModIndex]] followed by [[GetNthModName]] to create a load order protected parent stringmap. This is somewhat convoluted, although a UDF([[Example UDF: GetRefData|example]]) could simplify implementation. | |||
<pre> | <pre> | ||
let MyKey := $SomeActor ; or: | let MyKey := $SomeActor ; or: | ||
Line 53: | Line 54: | ||
==NX Variables== | ==NX Variables== | ||
Added by the [[NX]] plugin for NVSE, | Added by the [[NX]] plugin for NVSE, these are probably the most powerful way to associate data with a reference. Of course, the plugin is then required by all users. | ||
*Any number of persistent variables of either numeric, form or string may be stored on any reference. | *Any number of persistent variables of either numeric, form or string may be stored on any reference. | ||
*NX variables are fully accessible to all mods without needing masters. If attempting to retrieve a variable that does not exist, the value 0 is simply returned. | *NX variables are fully accessible to all mods without needing masters. If attempting to retrieve a variable that does not exist, the value 0 is simply returned. |