intro   modes   commands   objects   attributes   parameters   timing   variables, constants   forces   todo


Variables and predefined constants

contents

Variables
Predefined Constants


Variables

Variables can use any word that is not reserved. It makes sense to capitalise the first letter of user variables to distinguish them from other words. Capitalisation is important, for example Box is different to box, with "Box" being a variable defined by the user and "box" being the predefined box object. It would be wise to avoid such similar names though. Apart from the potential confusion for the user when reading and trying to make sense of files, it could make for great problems on operating systems where case is not significant (like Microsoft Windows) when something may be defined in a separate file and that file's case then becomes indeterminate.

Variables may appear almost anywhere and form the basis of value passing.
Example:
    box
        Switch=over
        color Switch+0.4 Switch+0.4 Switch
    // in this example a dull yellow box becomes white
    // whenever the mouse is passed over it


Predefined constants

Include files will not only be a way of defining and re-using complex shapes but will also be used to predefine many useful values. The define command marks a definition for the include command. It is really only of use in include files. It may be used in ordinary world files but may be omitted. In an include file you might use
    define LightBlue=color 0.74902 0.847059 0.847059

but in an ordinary world file the define command becomes optional so that you might write
    SpecialBlue=color 0.1 0.5 1

Different families of definitions will be separated into different include files so that you have a choice over which ones you want. This will not be so important in the early stages, but I expect that include files will be the fastest growing aspect of this language, and pretty soon there will be hundreds of textures, colors, unit conversions, handy values, etc.
Examples:
handy units
    define PI=3.1415926535897932384626433832795
    define EarthGrav=9.80665     //meters per sec-2
    define MoonGrav=1.62     //meters per sec-2
    define EarthRadius=6378000000     //meters
    define MoonRadius=1738000     //meters
    define SpeedSound=331     //meters per sec
conversions
    define Inch=0.0254     //meter
    define Ft=0.3048     //meter
    define Mile=1609.344     //meters
    define Angstrom=0.0000000001     //=1 nanometer
colors
    define Red=color 1 0 0
    define Green=color 0 1 0
    define Blue=color 0 0 1
    define Yellow=color 1 1 0
    define Aqua=color 0 1 1
    define Fuschia=color 1 0 1
    define White=color 1 1 1
    define Black=color 0 0 0
    define Teal=color 0 0.5 0.5
    define LightBlue=color 0.74902 0.847059 0.847059



intro   modes   commands   objects   attributes   parameters   timing   variables, constants   forces   todo

Maintained by Miriam English