Posted by Antony Espindola on July 15, 1998 at 04:57:31:
In Reply to: Re: Hidden Walls solution posted by jm on July 14, 1998 at 10:06:21:
Just to clear this confusion up...
The Symbols section is where you declare all the variables that
you are going to use in your COG code. You need to do this so
that the game engine can allocate memory space for them and also
so that you can enter values in the "Placed COGs" window.
There are two types of symbols- normal and local.
The normal variables are ones which appear in in the
"Placed COGs" window so that you can enter values for them, such
as which Thing to move, or which Surface you want as a switch.
The local variables are ones which you cannot see in
the "Placed COGs" window and are only used inside the COG code.
The only difference between them is that "local" variables have
an extra declaration of "local" after them in the Symbols section.
If I wrote a COG which simply changes the Texture to the second
MAT (like when a switch is pressed and it lights up) then I would
need some variables for:
if (SwitchIsOn == 0)
{
SwitchIsOn =1;
SetWallCel(MyButton, 1);
Sleep(Delay);
SetWallCel(MyButton, 1);
SwitchIsOn =1;
}
Return;
The "SwitchIsOn" variable will only ever be set to
one or zero and is internal to our COG, so it can
be defined as local - we don't need change it from
outside the COG.
The "MyButton" variable, our surface we change, needs to be
set from outside the COG, so that has to be a normal variable.
The "Delay" variable, how long the surface is lit, could
be a local variable, but if we make it a normal variable, we
can easily change it in the "Placed COGs" window rather than
rewriting our COG!
So this is what our Symbols section would look like: surface MyButton end
symbols
float Delay=5.5
int SwitchIsOn=0 local
See how these are defined?
I've purposely set "Delay=5.5" because this will initialise
our variable with a value of 5.5 when the COG is looked at.
This gives us a default value in our "Placed COGs" window.
I've done the same with the "SwitchIsOn" variable but this
time set it to zero when it is initialised, so we can use
our switch code.
The definitions of the variables should be obvious-
a "surface" is just that, a surface in the level,
an "int" is an integer, or whole number, like 4 (but not 4.3)
a "float" (don't use "flex"!) is a number with a decimal point, like 4.3 (but can include 4)
a "vector" is a description of a direction that something travels along, like a conveyor belt
a "thing" is an object, such as an ammo pack or a droid
a "template" is used when creating things, like an explosion or smoke
I hope this helps to clear up any confusion about the symbols section.
Have a look at the JK Specs for more details!