Difference between revisions of "Cross Script Variables"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>DragoonWraith
(discussion tag)
imported>Bruneauinfo
(Found the solution!! Working on the article!!)
Line 1: Line 1:
{{Discussion}}
{{Discussion}}


I had been looking for a way to get the value of a variable from a script running in one object to a script running in another object. I am not sure this works the way I believe it does, and I plan on testing this in the near future.  
If you are looking for a way to get the value of a variable from one script running on one object to a script running on another object I can imagine you may have entered the above article name in your search or something similar to it. As you first begin writing mods you may notice that the scripting language of Oblivion assumes the only universally accessible variables should be Global variables. This would not be terrible except that all Global variables are treated as ''floats''. (See [[Floating Point]].)


However, if it is indeed the way to do this I'll go ahead and add that finding this particular functionality was NOT very intuitive on the wiki. So I went ahead and created this entry using the search parameter I felt was most intuitive for finding this in the future. So when I or anyone else using the Wiki is looking for this information they may be able to find it more readily.  
It is possible the time will come in writing a script for a mod when you will wish to have a repository to store variables in that can be read from and written to by any script. Fortunately this is quite possible. This article addresses a method for not only storing non-float numeric values, but also object references. This could prove very handy when creating dynamic game scenarios.  


If it turns out this functionality is just not available, or not what I thought it was, then I hope this page is left alive for the sake of posterity.
A basic scenario for creating and testing this type of functionality includes three parts.  


Here's the function I'm referring to: [[GetScriptVariable]]
1 - A quest script used to act as the database for storing the values. One might want to read over the following article to get familiar with [[Quest scripts]].


Ironically if a person searches the Wiki using the title of this entry they will not find this function directly although [[GetQuestVariable]] will be listed.  
2 - A script that writes a value to one of the variables in the "database" Quest script when it is activated.  


(''They'll find it now, of course!!'')
3 - A script that reads a value from one of the variables in the "database" Quest script when it is activated.
 
(note: i will finish this article later tonight!!)


===See Also===
===See Also===


*[[GetScriptValue]]
*[[GetGlobalValue]]
*[[GetGlobalValue]]
*[[GetQuestVariable]]
*[[GetQuestVariable]]

Revision as of 19:27, 22 December 2010


If you are looking for a way to get the value of a variable from one script running on one object to a script running on another object I can imagine you may have entered the above article name in your search or something similar to it. As you first begin writing mods you may notice that the scripting language of Oblivion assumes the only universally accessible variables should be Global variables. This would not be terrible except that all Global variables are treated as floats. (See Floating Point.)

It is possible the time will come in writing a script for a mod when you will wish to have a repository to store variables in that can be read from and written to by any script. Fortunately this is quite possible. This article addresses a method for not only storing non-float numeric values, but also object references. This could prove very handy when creating dynamic game scenarios.

A basic scenario for creating and testing this type of functionality includes three parts.

1 - A quest script used to act as the database for storing the values. One might want to read over the following article to get familiar with Quest scripts.

2 - A script that writes a value to one of the variables in the "database" Quest script when it is activated.

3 - A script that reads a value from one of the variables in the "database" Quest script when it is activated.

(note: i will finish this article later tonight!!)

See Also