Editing Mod Hooks

Jump to: navigation, search

Warning: You are not logged in.

Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 7: Line 7:
 
== Server Hooks ==
 
== Server Hooks ==
  
*Server_Created (Server_Created.lua)
+
Server_Created (Server_Created.lua)
 
** Called in every game when the game is first created.  In multi-player, this means it's called before players even accept or join the request for the game.  This is the only place that game settings can be changed.
 
** Called in every game when the game is first created.  In multi-player, this means it's called before players even accept or join the request for the game.  This is the only place that game settings can be changed.
 
** Return value: None.
 
** Return value: None.
Line 33: Line 33:
  
 
* Server_AdvanceTurn_Start (Server_AdvanceTurn.lua)
 
* Server_AdvanceTurn_Start (Server_AdvanceTurn.lua)
** Called whenever the server begins processing a normal turn (not territory picking).  This gives mods an opportunity to insert orders at the start of a turn, before any player's orders are added.  All of the Server_AdvanceTurn_* hooks share global state within a single turn, so global variables can be read and written reliably by mods.
+
** Called whenever the server begins processing a normal turn (not territory picking).  This gives mods an opportunity to insert orders at the start of a turn, before any player's orders are added.  All of the Server_AdvanceTurn_* turns share global state within a single turn, so global variables can be read and written reliably by mods.
 
** Arguments:
 
** Arguments:
 
# [[Mod API Reference:Game|Game]]: Provides read-only information about the game.
 
# [[Mod API Reference:Game|Game]]: Provides read-only information about the game.
# addNewOrder: A function that you can call to add a [[Mod API Reference:GameOrder|GameOrder]] to the start of the turn.  You may call this function multiple times if you wish to add multiple orders.  Pass a single GameOrder as the first argument to this function.   
+
# addNewOrder: A function that you can call to add a [[Mod API Reference:GameOrder|GameOrder]] to the start of the turn.  Pass a single GameOrder as the only argument to this function.  You may call this function multiple times if you wish.
 
+
 
+
 
+
  
  
Line 52: Line 49:
 
## WL.ModOrderControl.Skip: Indicates this order should be skipped.  It won't appear in the orders list at all and it will be as if the order never existed.  A [[Mod API Reference:GameOrderEvent|GameOrderEvent]] will be written into the orders list to tell the player who entered this order that their order was skipped.
 
## WL.ModOrderControl.Skip: Indicates this order should be skipped.  It won't appear in the orders list at all and it will be as if the order never existed.  A [[Mod API Reference:GameOrderEvent|GameOrderEvent]] will be written into the orders list to tell the player who entered this order that their order was skipped.
 
## WL.ModOrderControl.SkipAndSupressSkippedMessage: Same as Skip, except that the GameOrderEvent is not written.  This should be used with care, as players will want to know why their order didn't appear in the orders list.  This should only be used if you use some other mechanism to explain to the player why their order was not present, or if this is an order that your mod inserted and therefore no players were expecting it.
 
## WL.ModOrderControl.SkipAndSupressSkippedMessage: Same as Skip, except that the GameOrderEvent is not written.  This should be used with care, as players will want to know why their order didn't appear in the orders list.  This should only be used if you use some other mechanism to explain to the player why their order was not present, or if this is an order that your mod inserted and therefore no players were expecting it.
# addNewOrder: A function that you can call to add a [[Mod API Reference:GameOrder|GameOrder]] to the start of the turn.  You may call this function multiple times if you wish to add multiple orders.  Pass a single GameOrder as the first argument to this function.   Optionally, you can also pass "true" as a second argument to this function to make your new order get skipped if the order this hook was called on gets skipped, either by your mod or another mod.  This second argument was added in [[Mod_API_Reference:IsVersionOrHigher|5.17.0]].
+
# addNewOrder: A function that you can call to add a [[Mod API Reference:GameOrder|GameOrder]] to the turn, which will be inserted just after the current order.  Pass a single GameOrder as the only argument to this function. You may call this function multiple times if you wish.
  
  
Line 59: Line 56:
 
** Arguments:
 
** Arguments:
 
# [[Mod API Reference:Game|Game]]: Provides read-only information about the game.
 
# [[Mod API Reference:Game|Game]]: Provides read-only information about the game.
# addNewOrder: A function that you can call to add a [[Mod API Reference:GameOrder|GameOrder]] to the start of the turn.  You may call this function multiple times if you wish to add multiple orders.  Pass a single GameOrder as the first argument to this function.   
+
# addNewOrder: A function that you can call to add a [[Mod API Reference:GameOrder|GameOrder]] to the end of the turn.  Pass a single GameOrder as the only argument to this function.  You may call this function multiple times if you wish.
  
  
 
* Server_GameCustomMessage (Server_GameCustomMessage.lua)
 
* Server_GameCustomMessage (Server_GameCustomMessage.lua)
 
** Called whenever your mod calls [[Mod API Reference:ClientGame|ClientGame]].SendGameCustomMessage.  This gives mods a way to communicate between the client and server outside of a turn advancing.  Note that if a mod changes Mod.PublicGameData or Mod.PlayerGameData, the clients that can see those changes and have the game open will automatically receive a refresh event with the updated data, so this message can also be used to push data from the server to clients.
 
** Called whenever your mod calls [[Mod API Reference:ClientGame|ClientGame]].SendGameCustomMessage.  This gives mods a way to communicate between the client and server outside of a turn advancing.  Note that if a mod changes Mod.PublicGameData or Mod.PlayerGameData, the clients that can see those changes and have the game open will automatically receive a refresh event with the updated data, so this message can also be used to push data from the server to clients.
** [[Mod_Security|Mod security]] should be applied when working with this Hook
 
 
** Arguments:
 
** Arguments:
 
# [[Mod API Reference:Game|Game]]: Provides read-only information about the game.
 
# [[Mod API Reference:Game|Game]]: Provides read-only information about the game.
Line 70: Line 66:
 
# payload: The data passed as the ''payload'' parameter to SendGameCustomMessage.  Must be a lua table.
 
# payload: The data passed as the ''payload'' parameter to SendGameCustomMessage.  Must be a lua table.
 
# setReturn: Optionally, a function that sets what data will be returned back to the client.  If you wish to return data, pass a table as the sole argument to this function.  Not calling this function will result in an empty table being returned.
 
# setReturn: Optionally, a function that sets what data will be returned back to the client.  If you wish to return data, pass a table as the sole argument to this function.  Not calling this function will result in an empty table being returned.
 +
  
 
== Client Hooks ==
 
== Client Hooks ==
Line 102: Line 99:
  
 
* Client_GameRefresh (Client_GameRefresh.lua)
 
* Client_GameRefresh (Client_GameRefresh.lua)
** Invoked whenever the client gets data about this game from the server.  This can be used to check for updated Mod.PublicGameData or Mod.PlayerGameData, documented at [[Mod Game Data Storage]].  The client refresh timing is different between single-player and multi-player, and in multi-player can also vary depending on the user's internet connection (such as whether they're connected by websocket, long polling socket, or normal polling).  Therefore, a mod should never write code that breaks if Client_GameRefresh is called at unexpected times.
+
** Invoked whenever the client gets data about this game from the server.  This can be used to check for updated Mod.PublicGameData or Mod.PlayerGameData, documented at [[Mod Game Data Storage]]
 
** Arguments:  
 
** Arguments:  
 
# [[Mod API Reference:ClientGame|ClientGame]]: Information about the game.
 
# [[Mod API Reference:ClientGame|ClientGame]]: Information about the game.
 
 
* Client_PresentCommercePurchaseUI (Client_PresentCommercePurchaseUI.lua)
 
** Invoked whenever the player clicks the "Build" button in a commerce game.  This can be used to present UI to allow the player to spend their gold on things.
 
** Arguments:
 
# rootParent: Pass this as an argument to the top-level UI element your mod creates.  See the [[Mod API Reference:UI|UI API]] for details.
 
# [[Mod API Reference:ClientGame|ClientGame]]: Information about the game.
 
# close: Function that, when called, will close the current dialog.  Takes no arguments and returns nothing.
 
  
 
== Notes ==
 
== Notes ==
Line 124: Line 113:
 
* [[Mod Developers Guide]]
 
* [[Mod Developers Guide]]
 
* [[Mod Game Data Storage]]
 
* [[Mod Game Data Storage]]
[[Category:Mod Developers Guide]]
 

Please note that all contributions to Warzone Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Warzone Wiki:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox