An Introduction to Variables
From Creatures Wikia
| Some information in this article seems to be inaccurate and should be fixed..|
More information may be available in the talk page.
Obviously, any prior experience in programming is going to be beneficial here, but I'm pretty confident that with my, terrible typos, enough feedback and revisions that this guide might prove pretty handy sometime.
Part 1 - An Introduction To Variables
First though, I'd like to run over a few different variable types, just in case. (yeah it gets more exciting, but you need to know this!)
Though you don't really need to worry much how the game stores these, it is a good idea to know your ass from your elbow to begin with.
STRINGS: Consider strings, a long string of characters(letters and numbers) joined together to produce something readable. In general, strings are things which can be read and written, but they are not numbers, which can be calculated , etc. For example, "Greetings to the CC" is a string, as is "10 jellyfish", "Satan666" , and "345".
Note that the numbers included, even "345" (while it is a string) should not be considered a number, as such.
NUMBERS: We all know what they are, and the game kindly doesn't worry about positive/negative numbers and decimal points for the most part :D. The difference between 345 and "345" (as a string) though is that 345 is a number, and if you add one to it you will get 346.... You can't add 1 to "345", cause the game thinks it's text. That's like trying to ask it to multiply "moop" by two.. you just can't!
AGENTS: This isn't standard to most any programming language, but with CAOS you'll be glad they're there. An agent in creatures is most ANYTHING you see in the world, from Norns, to the Hand, to Butterflies, to the doors. The only exclusion would be the background.
You'll see quite clearly why you need to know the difference between strings, numbers, and agents later on :)
Part 2 - Game Variables
The game has a few ways of storing variables... for example..
- ov01, ov02, ov03, up to ov99
- va01, va02, va03, up to va99
- and then of course there's the global variables.
Something on scripts before variable types are explained...
Let's use the word agent and object interchangably here, unless I say otherwise. Now, you already know that everything in Creatures (just about) revolves around scripts; scripts written in CAOS. And each script will control how the object/agent is controlled.
The variables of the type "ov00" are specific to the single target object. They will not affect any other object in the game. Here's an example, say the target object for this script is an egg (more on targets later), the game must know somewhere whether the egg is a male, a female or random... This information is stored in an Object Variable (ov). In this case, the egg uses ov01. The sex all depends on what's stored in ov01.
If ov01 were to be 1 (i.e. the number 1 was stored), the egg will be female.. if it is 2, the egg is random, and if it's 0, the egg is male. So it's handy to think of the object variables as sub-parts to the object. These subparts are what each object needs stored about it's self.
However, object variables are specific to each object. So ov01 for say, the egg Harriet laid five minutes ago, could possibly be different to ov01 for the egg Tania laid just this minute, since they might well be different sexes.
Other object variables, i.e. ov03 , might represent how big the egg is currently.
General Variables, however, are not specific to any singluar object, but only to the script that is currently running. For example, imagine the program is going to set all of the eggs in the game to female.. The script would go something like:
set the value of va66 to 1 (any va variable number can be used at this point) select first egg set ov01 (sex) to the value stored in va66 . (i.e. ov01 becomes 1) select the next egg and repeat.
Okay, that was a bit of a useless example, but va66, or whatever variable you use will be the same no matter which object is being used, but only for the duration of this script!
When the game executes another script, it will use the va66 value specified there, or va55, or va23 etc...
C3 max norns
The last type come in the form of "c3_max_norns". Any script can read off this variable, which makes it really handy for things like the egglayer to say to itself.. "Hey, have we hit the maximum number of norns yet?"
For example if "C3_max_norns" was equal to 12, the incubator would suck itself back in and eggs would stop hatching until another norn was removed. You can now see how variables like this can be accessed by the Egg hatching script *and* the incubator's scripts.
Unlike ov and va, the values remain unchanged at all times, and accessible by any script.
Right, that's all Im going to preach on variables for now. It's time to do some caos. :)
Next Part --> Inject Your First Object