Difference between revisions of "Cross Script Variables"
Simplified the beginning and took out some unnecessary information.
imported>Bruneauinfo m (Get Script Variable moved to Cross Script Variables: Renaming the page and putting a link to it under scripting basics.) |
imported>Bruneauinfo (Simplified the beginning and took out some unnecessary information.) |
||
|
▲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 ==
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. In this article
2 - A script that writes a value to one of the variables in the "database" Quest script when it is activated.
=== The Quest Script ===
The quest script acts
The script:
Make sure you set the Script Type as "Quest" in the script editor window and then save your script.
The script is very simple. You just declare all the variables you need for storing values.
====Notes====
*The variable names listed in the script can be named whatever you like - preferably something meaningful to their purpose.
*You must declare a variable in the quest script and compile it BEFORE you can reference them in the read/write scripts described below. If you attempt to code your read/write commands and the variable has not yet been declared in the quest script you will receive a compiling error in your read/write script. (''specifically this error message will state that your variable is an unknown variable or command even though you have declared the variable already within the read/write script.'')
| |||