CallMapScript

From Spheriki

Jump to: navigation, search

Calls the given map script.

Contents

Usage

CallMapScript(script_name);
  • script_name A Constant type from list given below:
    • SCRIPT_ON_ENTER_MAP
    • SCRIPT_ON_LEAVE_MAP
    • SCRIPT_ON_LEAVE_MAP_NORTH
    • SCRIPT_ON_LEAVE_MAP_EAST
    • SCRIPT_ON_LEAVE_MAP_SOUTH
    • SCRIPT_ON_LEAVE_MAP_WEST

Examples

Once a map is loaded via the MapEngine() function, the "On Enter" script for the given map is executed, and is normally defined to initialize persons and triggers on the map, or just to switch control to a user defined loop. This initialization however can be useful during game play on the map as well, and may be useful to have repeated. For example, during a maze puzzle, if the player gets it wrong, it may have to be reset and the player set back to the beginning, in which case just calling the beginning initialization code would be effective. As such, one could do something as follows:

if (PlayerScrewedUp())
{
  failed_attempts++; //record the number of tries
  CallMapScript(SCRIPT_ON_ENTER_MAP);
}

Notes

  • This function will only work while the map engine is running. This condition can be checked for using the IsMapEngineRunning() function.
  • The Constant types used as the arguements in this function are actually integer values. As such, you can also

store this information in an array (eg: array[SCRIPT_ON_LEAVE_MAP] = "...";)


See also

Personal tools