Global Arrays
I know that I'm going to need to use some global arrays to handle skill checks, and such, in my project; but I have no example to use as a guideline for this.
In the project for which I need then, each array would have 256 values in it, with each value matching an item editor value. Note, that I don't need an example that includes 256 values: Producing an example set of arrays and functions that use them, to store values, reset values, etc., as a template, I would appreciate it greatly. As I said, I don't need to see an example array with 256 values, but something with say, ten values, would be fine, because expanding it, once I know how it works, is easy for me.
Once I have a template from which I can work, I can do some pretty amazing things, but working without any living example is very hard, as I am an extremely visual person. I don't even know what the maximum number of values that can be stored in an array is in ZScript.
My Intended Usage
This is something that I need to use, in order to actually implement a skill check system, because otherwise, I't need hundreds of global variables, just to track checks, failures, and successes.
While many items wont use these values initially, I think it would be easier to track all 256 possible values, than to only use the values that I need, because if any of them change, then the work involved with fixing all the functions that are tied to them is absurdly convoluted.
If it is just a numeric list of 0 through 255, then anything that calls to them can be easily translated using the item number value, and if I add items, or change items, the function will remain the same. item 121, will always be the 121st array value, in any set of arrays, and related functions, that work in this manner.
The way that I will need this to work, is to store a value of 0, 1, 2, or 3, for each item in the game (arrayItemLore), in an array; and a value of 0, 1, or 2, for each item, in a second array (arrayChecked).
Then, if Link makes a Lore check on the item, first, the game sets the vale tied to that item in arrayChecked to 1, because he has made a Lore check attempt] a failure sets the value from 0 to 1, and a success sets the value from 0 to 2.
If the value of this part of the arrayChecked is 2, then the value stored in arrayItemLore, for that one item, increases by 1, which triggers a secondary function, that upgrades the item, displays strings, makes fanfare, etc..
If he fails, the value for that item in the arrayChecked array is set to 1, and any new attempt to check that item will report something like 'You must improve your skill before you may make a new Lore Skill Check on this item'.
Either way, if the value is not 0 then the player can't make a new check until the value in arrayChecked is reset to 0.
Gaining a level would reset all values in arrayChecked to 0, to allow new checks on items when your Lore skill increases. I will probably need to make a variety of these arrays, to track items, places, people, and other lore, but what I really need is a working, living example of how to make global arrays, and functions that use them, including reading from, and writing to the array values.
That's the basic idea. I'd appreciate a sampling of example global arrays, and functions that use them. Thank you all for your time, and consideration.
P.S. Examples that don;t include separate functions to read from a global array, and to write to a global array, will not be helpful to me; and examples that aren't actually functional also aren't useful. What I need to have in order to do this, is a working example of handling global arrays, that includes reading values from them, and writing values to them, using global functions.
Edited by ZoriaRPG, 20 April 2014 - 10:12 AM.

