Difference between revisions of "Talk:Reference Variables"
imported>Scruggs |
imported>Scruggs |
||
Line 21: | Line 21: | ||
Looking at this description from the article: | Looking at this description from the article: | ||
<pre>Keep in mind, that References to non-persistent objects aren't accessible when the object is not in memory (i.e. in another cell) The same applies to inventory items that are currently within a container. Trying to access a non-accessible reference might have no effect at all, but it's equally probable that it will crash the game. While there are safeguards in the CS to prevent you from accessing such references directly, you can bypass them by using reference-variables. </pre> | <pre>Keep in mind, that References to non-persistent objects aren't accessible when the object is not in memory (i.e. in another cell) The same applies to inventory items that are currently within a container. Trying to access a non-accessible reference might have no effect at all, but it's equally probable that it will crash the game. While there are safeguards in the CS to prevent you from accessing such references directly, you can bypass them by using reference-variables. </pre> | ||
...If I'm understanding that right, a variable that stores a reference to a non-persistent object is valid as long as the cell is loaded, even after the cell has been reset or a savegame is loaded? [[User:Scruggs|Scruggs]] 00:23, 20 July 2006 (EDT) | ...If I'm understanding that right, a variable that stores a reference to a non-persistent object (such as one created via placeAtMe) is valid as long as the cell is loaded, even after the cell has been reset or a savegame is loaded? [[User:Scruggs|Scruggs]] 00:23, 20 July 2006 (EDT) |
Revision as of 23:24, 19 July 2006
How are reference variables stored internally. I'm having issues reliably accessing my reference variables when there get to be more than 16 user created ones in a cell. I get correct behaviour sometimes but not all the time. I can provide an ESP and simple instructions to replicate the problem. It is possible it is my code however which is why I would like to try and eliminate as many issues as possible, since you certainly don't have time to be debugging my scripts.
On further testing, I see that the same code works perfectly sometimes and not others. Is it possible to hit race conditions in scripts? I assumed they would be linearly processed with no interruption. If that's not the case, then the errors I am getting virtually require that the references I have stored are variable and not fixed as I would expect. Almost nothing else describes this behavior. --Tegid 00:16, 24 April 2006 (EDT)
I'm not sure what you mean by "race conditions in scripts". Script processing is threaded, however, so several scripts can be processed simulataneously, if that's what you're referring to. --Kkuhlmann 08:02, 25 April 2006 (EDT)
That's what I mean. So two scripts can be running simultaneously both of them operate on the same persistent data, we can have data races. Do you run blocks of scripts together (ie, do you split the scripts into separate threads on groups of 16 scripts (or 32)) I ask that because things work correctly, reliably with 16 new objects, but with 18 (I create two at a time) things stop working reliably (they more reliably fail to work). --Tegid 09:16, 25 April 2006 (EDT)
CAVEAT: Objects created by leveled lists do not process in low, if you set a reference variable from a leveled list, if your script tries to refer to that reference variable when that actor isn't loaded, bad things will happen. So don't ever do a "set myRefVariable to myXmarker.placeAtMe myLeveledList". Instead create an if-then section in a script which checks the player level, pick an appropriate base object for the players level, then do a "set myRefVariable to myXmarker.placeAtMe SpecificBaseObjectID".--Jduvall
- This happens when you try to refer non-persistent objects or those that can be put in a container, not a specific problem with reference variables or leveled lists.--JOG 17:19, 24 May 2006 (EDT)
CAVEAT 2: You can not pass reference variables IN OTHER SCRIPTS as parameters to functions that take references. You must first set a local reference variable. For example: "myCharacterRef.look MyQuestScript.myReferenceVariable" will fail whereas "myCharacterRef.look myReferenceVariableDeclaredInThisScript" will work just fine. So in the local script just declare a "ref myReferenceVariableDeclaredInThisScript" and then set it to the external one "set myReferenceVariableDeclaredInThisScript to MyQuestScript.myReferenceVariable", and use the local one.--Jduvall
- You can't use ANY variables this way.--JOG 17:19, 24 May 2006 (EDT)
Looking at this description from the article:
Keep in mind, that References to non-persistent objects aren't accessible when the object is not in memory (i.e. in another cell) The same applies to inventory items that are currently within a container. Trying to access a non-accessible reference might have no effect at all, but it's equally probable that it will crash the game. While there are safeguards in the CS to prevent you from accessing such references directly, you can bypass them by using reference-variables.
...If I'm understanding that right, a variable that stores a reference to a non-persistent object (such as one created via placeAtMe) is valid as long as the cell is loaded, even after the cell has been reset or a savegame is loaded? Scruggs 00:23, 20 July 2006 (EDT)