The scope of every script is one map. Global objects and functions will
only see each other on the same map. While it is possible to pass data
from one map to another, each time a map is loaded the script engine is
reset. The process of creating script space is as follows:
- The FCW or C3D map is loaded.
- The script engine is initialized.
- The system initialization script is parsed.
- The file Global.js is loaded from disk and parsed.
- Text contained in map note <CO3D.Map.PreLoad> will be
parsed as JScript. No processing of 2D map objects has occurred
yet, so access to 3D-specific functions, such as Overseer.GetEntity(),
is not available.
- The text contained in each map hotspot is processed as follows:
- Object thisEntity is created and thisEntity.tag
is set to the current hotspot tag.
- Text in tag <O3D.Entity.Init> is parsed. Hotspot
initialization parameters should be placed here and accessed using
the thisEntity object. (See object
description for details). The contents of this tag are parsed in
global scope. Setting global variables and calling functions is
permitted. Map 3D objects have not been created yet, so access to
3D-specific functions is still limited.
- When the script engine encounters the tag </O3D.Entity.Init>,
initialization for this hotspot ends.
- Text in tags <O3D.Entity.Activate> and <O3D.Entity.DeActivate>
is established as the body of functions ActivateEntityTag#
and DeActivateEntityTag#.
For example, if these tags were found in hotspot tag number 7764,
two functions would be declared:
ActivateEntity7764(activationType,
keyword) { text from tag <O3D.Entity.Activate> }
DeActivateEntity7764() { text from tag <O3D.Entity.Activate>
}
- Use the end tags </O3D.Entity.Activate> and </O3D.Entity.DeActivate>
to close each of these tags.
- Text contained in map note <CO3D.Map.PostLoad> is
parsed. This occurs on completion of all 3D initialization, thus the
use of 3D-specific functions, such as Overseer.GetEntity(),
is now permitted.
- When the user activates a hotspot, City Overseer 3D® calls
the appropriate ActivateEntityTag#
function. When the user deactivates a hotspot, the appropriate DeActivateEntityTag#
function is called.
- If the map contains a note with the name <CO3D.Map.TTR>,
the text inside the note is treated as a Terrain Texturing Rules (TTR)
file. This text TTR will have a datestamp. If this section's date is
newer than a map TTR file found on the hard drive, the entries here
will be used and will also overwrite the ones on the hard drive. If
the TTR file on the hard drive is newer, it will be used instead of
this note. This ensures that older versions of a map TTR file will
always be updated and used while also ensuring that newer versions of
the TTR file will still override and supersede settings in the map.
- When the user closes a map, either by loading another map or by
closing City Overseer 3D®, the program will run any scripts
found in map note <CO3D.Map.onExit>, if it is present,
prior to loading the new map or closing the program..
|