Difference between revisions of "LevelScripts"

From Wolfire Games Wiki
Jump to: navigation, search
m
m
Line 63: Line 63:
 
   // Optional - hook to allow receiving incoming network communication in the game client.
 
   // Optional - hook to allow receiving incoming network communication in the game client.
 
   // Called when a network TCP packet has been receieved
 
   // 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'''
+
   // 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) {
 
   void IncomingTCPData(uint socket, array<uint8>@ data) {
 
   }
 
   }

Revision as of 08:07, 25 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:

  1. level.as (in the file Data/Scripts/level.as)
  2. the level script specified in a given level, if any (specified in a <script>something.as</script> tag, inside some_level.xml)
  3. 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() {
 }
 // Optional - additional hook called as a second pass after the entire first set of DrawGUI hooks have been called
 void DrawGUI2() {
 }
 // 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 - 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) {
 }
 // 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) {
 }
 // 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) {
 }