Difference between revisions of "LevelScripts"
From Wolfire Games Wiki
m |
m (Updating order of functions based on use/required) |
||
Line 35: | Line 35: | ||
} | } | ||
− | // Optional - | + | // Required for base level script, Optional for level-specific level script, and per-mod level scripts. |
− | void | + | // Hook to allow messages to be passed between level scripts, or from moving object scripts to level scripts |
+ | void ReceiveMessage(string) { | ||
} | } | ||
Line 42: | Line 43: | ||
// Hook to handle resizing a custom GUI when the game window has been resized | // Hook to handle resizing a custom GUI when the game window has been resized | ||
void SetWindowDimensions(int new_width, int new_height) { | void SetWindowDimensions(int new_width, int new_height) { | ||
+ | } | ||
+ | |||
+ | // Optional - additional hook called as a second pass after the entire first set of DrawGUI hooks have been called | ||
+ | void DrawGUI2() { | ||
} | } | ||
Line 54: | Line 59: | ||
// TODO: What is str? | // TODO: What is str? | ||
void HotspotExit(string str, MovementObject @mo) { | void HotspotExit(string str, MovementObject @mo) { | ||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
Revision as of 00:20, 30 April 2017
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:
- level.as (in the file Data/Scripts/level.as)
- the level script specified in a given level, if any (specified in a <script>something.as</script> tag, inside some_level.xml)
- the level script hooks defined for each loaded mod, if any (specified in a <LevelHookFile>something.as</LevelHookFile> tag, inside mod.xml)
List of hook functions
// Required - called when the level is first loaded void Init(string level_name) { }
// Required - Note: Not called on per-mod level scripts. // TODO: What is this this used for? bool HasFocus() { return false; }
// 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 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 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. // 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 level script to draw a custom GUI. Can be empty void DrawGUI() { }
// 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 ReceiveMessage(string) { }
// 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 SetWindowDimensions(int new_width, int new_height) { }
// Optional - additional hook called as a second pass after the entire first set of DrawGUI hooks have been called void DrawGUI2() { }
// 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 HotspotEnter(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 HotspotExit(string str, MovementObject @mo) { }
// Optional - hook to allow receiving incoming network communication in the game client. // Called when a network TCP packet has been receieved // Note: Requires more setup in order to get any data or even be called, like a connection to the server. // See Data/ExampleMods/example_tcp_socket_mod void IncomingTCPData(uint socket, array<uint8>@ data) { }
// Required for base level script, not called on level-specific level script, or per-mod level scripts. // TODO: What is this used for? 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) { }