LevelScripts
From Wolfire Games Wiki
This page describes the hook functions that are called by the game inside level scripts, and what order level script functions are called
Level scripts have a hierarchy, and hook functions inside them are called in a specific order:
1. level.as 2. the level script specified in a given level, if any 3. the level script hooks defined for each loaded mod, if any
void Init(string level_name) { // Required - called when the level is first loaded }
bool HasFocus() { // Required - Note: Not called on per-mod level scripts. TODO: What is this this used for? return false; }
// Note: Only for a level-specific level script. Don't define in per-mod level scripts or in the base level script void Update() { // Required - hook to allow a level-specific script to regularly update itself on each game tick. Only called if the game is not frozen/paused. Can be empty }
// Note: Only for the base level script, and per-mod level scripts. Don't define in level-specific level scripts void Update(int is_paused) { // Required - hook to allow the base level script and per-mod level scripts to regularly update themselves on each game tick. is_paused is 0 if not paused, and 1 if paused. Can be empty }
void DrawGUI() { // Required - hook to allow the level script to draw a custom GUI. Can be empty }
void DrawGUI2() { // Optional - additional hook called as a second pass after the entire first set of DrawGUI hooks have been called }
void SetWindowDimensions(int new_width, int new_height) { // Required for base level script and for per-mod level scripts. Hook to handle resizing a custom GUI when the game window has been resized }
void HotspotEnter(string str, MovementObject @mo) { // Optional - called when a hotspot inside the level is entered by a moving object. Note: called after any "HotspotExit" hook is called. TODO: What is str? }
void HotspotExit(string str, MovementObject @mo) { // Optional - called when a hotspot inside the level is exited by a moving object. Note: called before any "HotspotEnter" hook is called. TODO: What is str? }
void ReceiveMessage(string) { // Required for base level script, Optional for level-specific level script, and per-mod level scripts. Hook to allow messages to be passed between level scripts, or from moving object scripts to level scripts }
void IncomingTCPData(uint socket, array<uint8>@ data) { // Optional - hook to allow receiving incoming network communication in the game client. Called when a network TCP packet has been receieved }
void SaveHistoryState(SavedChunk@ chunk) { // Required for base level script, not called on level-specific level script, or per-mod level scripts. TODO: What is this used for? }
void ReadChunk(SavedChunk@ chunk) { // Required for base level script, not called on level-specific level script, or per-mod level scripts. TODO: What is this used for? }