Difference between revisions of "Cross Script Variables"

604 bytes removed ,  23:04, 23 December 2010
Got rid of quote requirement statements and quotes.
imported>Bruneauinfo
imported>Bruneauinfo
(Got rid of quote requirement statements and quotes.)
Line 78: Line 78:
  begin onActivate
  begin onActivate
   
   
   set "MyQuest".refVar to "ObjectReference" ; or some reference variable
   set MyQuest.refVar to ObjectReference ; or some reference variable


   set "MyQuest".floatVar to 1234567890 ; or some float variable
   set MyQuest.floatVar to 1234567890 ; or some float variable


   set "MyQuest".ShortVar to 2012 ; or some integer variable
   set MyQuest.ShortVar to 2012 ; or some integer variable


  end
  end
Line 89: Line 89:


That's it! Now associate this script with some object that can be "activated". When the player or an actor activates the object the values listed above will be assigned to the script variables in the quest script.  
That's it! Now associate this script with some object that can be "activated". When the player or an actor activates the object the values listed above will be assigned to the script variables in the quest script.  
It's very important to notice where quotes were used in the example script. These are '''required'''. If the quotes are not used the script will fail to work properly. Yes, the script will compile, but the values will not be written to the quest script. References as well as the reference for the quest require these quotation marks. However, in the case of a reference variable - ''quotes are only required when setting the value of the reference variable''.
set "MyQuest".refVar to ThisReferenceVar


=== Reading a Value ===
=== Reading a Value ===
Line 117: Line 113:
begin OnActivate
begin OnActivate


set refVarRetrieved to "MyQuest".refVar
set refVarRetrieved to MyQuest.refVar


set floatVarRetrieved to "MyQuest".floatVar  
set floatVarRetrieved to MyQuest.floatVar  


set ShortVarRetrieved to "MyQuest".ShortVar
set ShortVarRetrieved to MyQuest.ShortVar


MessageBoxEx "See my reference: %n See my float: %g See my integer: %.0f", refVarRetrieved, floatVarRetrieved, ShortVarRetrieved
MessageBoxEx "See my reference: %n See my float: %g See my integer: %.0f", refVarRetrieved, floatVarRetrieved, ShortVarRetrieved
Line 129: Line 125:
</pre>
</pre>


Again the quotes around the name of your quest are critical for this to work. Also, if you use this script exactly as written the message box will show the name of your reference rather than the reference. See [[MessageBoxEx]] for more. But the reference value is there and ready for use.  
If you use this script exactly as written the message box will show the name of your reference rather than the reference. See [[MessageBoxEx]] for more. But the reference value is there and ready to use.  


== Practical Applications ==
== Practical Applications ==
Anonymous user