Difference between revisions of "Cross Script Variables"
no edit summary
imported>Bruneauinfo (→Notes) |
imported>Bruneauinfo |
||
Line 1: | Line 1: | ||
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 imagine you may have entered the above article name or something similar to it in your search for an answer. As you first begin writing mods you will probably notice that Oblivion assumes the only variables that should be universally accessible are the Global variables. This would not be a terrible thing except that all Global variables are treated as ''floats''. (See [[Floating Point]].) | 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 imagine you may have entered the above article name or something similar to it in your search for an answer. As you first begin writing mods you will probably notice that Oblivion assumes the only variables that should be universally accessible are the Global variables. This would not be a terrible thing except that all Global variables are treated as ''floats''. (See [[Floating Point]].) | ||
It is possible a time will come in writing a script when you will wish to have a repository to store variable values that can be read from and written to by any script. Fortunately this is possible. This article addresses a method for not only storing and retrieving non-float numeric values, but object references as well. This could prove very handy when creating dynamic game scenarios. | It is possible a time will come in writing a script when you will wish to have a repository to store variable values that can be read from and written to by any script. Fortunately this is possible. This article addresses a basic method for not only storing and retrieving non-float numeric values, but object references as well. This could prove very handy when creating dynamic game scenarios. | ||
== The Basics == | == The Basics == | ||
Line 7: | Line 7: | ||
A scenario for creating and testing this type of functionality includes at least three features: | A scenario for creating and testing this type of functionality includes at least three features: | ||
1 - A script that acts as the database for storing values. (One might want to read over the article [[Quest scripts]] to get familiar with the source of this idea.) | 1 - A script that acts as the database for storing values. In this article the Quest Script method will be demonstrated. (One might want to read over the article [[Quest scripts]] to get familiar with the source of this idea.) | ||
2 - A script that writes a value to one of the variables in the "database" Quest script when it is activated. | 2 - A script that writes a value to one of the variables in the "database" Quest script when it is activated. |