Difference between revisions of "Talk:Reference Variables"

3,032 bytes added ,  07:31, 8 September 2008
Reference Isolation? Bethesda seem to know a way to circumvent this issue. I wanna know!
imported>Dev akm
imported>Antares
(Reference Isolation? Bethesda seem to know a way to circumvent this issue. I wanna know!)
Line 88: Line 88:


:What sort of item and where are you trying to get the reference? References do not work on carryable items if they are in inventory (i.e., on an actor or in a container).--[[User:Dev akm|dev_akm]] 10:53, 19 August 2008 (EDT)
:What sort of item and where are you trying to get the reference? References do not work on carryable items if they are in inventory (i.e., on an actor or in a container).--[[User:Dev akm|dev_akm]] 10:53, 19 August 2008 (EDT)
==Isolation?==
How it is possible for scripts to declare and use a reference that is set in a separate script? Let me give you some context. In a mod that I am working on I have a '''better''' ''(yes, how we all love to outdo Bethesda)'' version of The Saviour of Bruma Statue. Mine can be updated and removed at will etc. '''Please note that I am not altering the Bruma Statue but merely have a similar in my abode.'''
My dilemna is that I have only been able to get the effectshader I am playing on the Statue to run in GameMode blocks. I wish to have be able to use something a little more comprehensive like an OnLoad block the challenge is having a reference that an OnLoad block can use. I anticipate that a seperate script will be required for this. The game would be forced to run this block on my statue without fail due to the way I am adding it to the game.
The Proof, If you look at the scripts that handle The Saviour of Bruma Statue you can see that the creation of the statue is handled in one script (MartinScript) and other finer points by another (MQ14StatueScript). In MartinScript the statue is assigned the reference variable of ''playerstatue''. This reference is used in the MQ14StatueScript. I was under the impression that such reference's were isolated to the script in which they are set and declared. Despite the already cluttered nature of this page I will post the relevant parts of the aforementioned scripts below.
'''MartinScript'''<BR>
<pre>ScriptName MartinScript
ref playerStatue
short scriptKill ; set to 1 if a script killed Martin, for debugging problems
begin OnLoad
if getstage MQ14 >= 50 && MQ14.createStatue == 0
set MQ14.createStatue to 1
MQ14PlayerStatueMarker.enable
set playerStatue to player.CreateFullActorCopy
playerStatue.removeItem torch02 1000 ; make sure the statue doesn't have a torch
playerStatue.addscriptpackage MQStatuePose
playerStatue.moveto MQ14PlayerStatueMarker
playerStatue.setalert 1
playerStatue.setghost 1
playerStatue.setunconscious 1
playerStatue.setdestroyed 1 ; so you can't activate player
playerStatue.setscale 1.8
playerStatue.setav speed 0 ; so you can't move it around
endif
end</pre>
'''MQ14StatueScript'''<BR>
<pre>scn MQ14StatueScript
short statueYear
ref playerStatue
short distancecheck
begin OnLoad  ;for playing an effectShader this is more comprehensive than a GameMode Block
if playerStatue == 0
set playerStatue to MartinRef.playerStatue ;!!!!!!HOW!!!!!!
endif
if playerStatue != 0
playerStatue.moveto MQ14PlayerStatueMarker
playerStatue.addscriptpackage MQStatuePose ; shouldn't be necessary but oh well
set statueYear to MQ14.victoryYear
playerStatue.pms effectstone
playerStatue.pickidle
endif
end</pre>
The winning bit of code seems to be this line:<BR>
<pre>set playerStatue to MartinRef.playerStatue</pre>
It seems to me that the above line uses a reference from the other script. Ideas anyone, how is this achieved?<BR>
--[[User:Antares|Antares]] 08:31, 8 September 2008 (EDT)
Anonymous user