Mod API Reference:ClientGame: Difference between revisions

From Warzone Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 8: Line 8:
* '''Settings''' ''[[Mod API Reference:GameSettings|GameSettings]]'': The settings this game uses.
* '''Settings''' ''[[Mod API Reference:GameSettings|GameSettings]]'': The settings this game uses.
* '''LatestStanding''' ''[[Mod API Reference:GameStanding|GameStanding]]'': The latest state of the game.
* '''LatestStanding''' ''[[Mod API Reference:GameStanding|GameStanding]]'': The latest state of the game.
* '''GetDistributionStanding''': A function used to get the [[Mod API Reference:GameStanding|GameStanding]] during the picking phase of this game.  Pass this function your own callback function which takes a [[Mod API Reference:GameStanding|GameStanding]] as an argument.  For example:  <code>game.GetDistributionStanding(function(standing) print('got ' .. standing) end)</code>.  Your function will be called with nil if the distribution standing is not available, for example if it's an automatic distribution game.  In the event of an error, such as lack of an internet connection, your callback will not be called.
* '''GetDistributionStanding''': A function used to get the [[Mod API Reference:GameStanding|GameStanding]] during the picking phase of this game.  Pass this function your own callback function which takes a [[Mod API Reference:GameStanding|GameStanding]] as an argument.  For example:  <code>game.GetDistributionStanding(function(standing) print('got ' .. standing) end)</code>.  Your function will be called with nil if the distribution standing is not available, for example if it's an automatic distribution game.  In the event of an error, such as lack of an internet connection, your callback will not be called and instead the player will get a "Could not connect" message.
* '''GetStanding''': A function used to get the [[Mod API Reference:GameStanding|GameStanding]] for any turn of the game.  Pass this function two arguments:  first, an integer represneting what turn to get (0 for the start of the game, 1 for the second turn, 2 for the third turn, etc.)  Second, pass a callback function that will get called with the [[Mod API Reference:GameStanding|GameStanding]].  See GetDistributionStanding for an example.
* '''GetStanding''': A function used to get the [[Mod API Reference:GameStanding|GameStanding]] for any turn of the game.  Pass this function three arguments:  The first argument is an integer representing what turn to get (0 for the start of the game, 1 for the second turn, 2 for the third turn, etc.)   The second argument is how many orders you want from that turn applied into the standing (specify 0 to get the start of the turn). Third, pass a callback function that will get called with the [[Mod API Reference:GameStanding|GameStanding]].  In the event of an error, such as lack of an internet connection, your callback will not be called and instead the player will get a "Could not connect" message.
* '''GetTurn''': A function used to get the [[Mod API Reference:GameTurn|GameTurn]] for any turn of the game.  Identical to GetStanding in every way, except that it calls back your function with a [[Mod API Reference:GameTurn|GameTurn]].
* '''GetTurn''': A function used to get the [[Mod API Reference:GameTurn|GameTurn]] for any turn of the game.  Identical to GetStanding in every way, except that it calls back your function with a [[Mod API Reference:GameTurn|GameTurn]].
* '''Orders''' ''List<[[Mod API Reference:GameOrder|GameOrder]]>'': Allows you to read and write the orders that the player is building up in the orders list for the current turn.  You can call this property to see the orders, or assign a list of orders to it to replace the player's orders with your list.
* '''Orders''' ''Array<[[Mod API Reference:GameOrder|GameOrder]]>'': Allows you to read and write the orders that the player is building up in the orders list for the current turn.  You can call this property to see the orders, or assign a list of orders to it to replace the player's orders with your list.
* '''CreateDialog''': A function used to create a new dialog on the screen for players to interact with.  Pass a single function callback as a argument to CreateDialog.  Your function callback will be passed the same arguments as the the Client_PresentMenuUI hook, documented at [[Mod Hooks]]
* '''CreateDialog''': A function used to create a new dialog on the screen for players to interact with.  Pass a single function callback as a argument to CreateDialog.  Your function callback will be passed the same arguments as the the Client_PresentMenuUI hook, documented at [[Mod Hooks]]
* '''SendGameCustomMessage''': A function used to send a message to the server, which will be handled by the Server_GameCustomMessage hook as documented at [[Mod Hooks]].  Note that this message is rate-limited to 5 calls every 30 seconds per client to avoid extra tax on the server.    Arguments:
* '''SendGameCustomMessage''': A function used to send a message to the server, which will be handled by the Server_GameCustomMessage hook as documented at [[Mod Hooks]].  Note that this message is rate-limited to 5 calls every 5 seconds per client to avoid extra tax on the server.    Arguments:
# '''waitText''': A string identifying what wait message will be displayed to the player as they're waiting for the server to reply.
# '''waitText''': A string identifying what wait message will be displayed to the player as they're waiting for the server to reply.
# '''payload''': Data that will be delivered to the Server_GameCustomMessage hook.  Must be a lua table.
# '''payload''': Data that will be delivered to the Server_GameCustomMessage hook.  Must be a lua table.
# '''callback''': A function you provide which will be called back when the message is complete.  If the message fails, such as due to a disconnected internet connection or an error in the server hook, this callback will not be invoked.  If it is invoked, it will be passed a single argument of a lua table that the Server_GameCustomMessage hook provided as a return value.
# '''callback''': A function you provide which will be called back when the message is complete.  If the message fails, such as due to a disconnected internet connection or an error in the server hook, this callback will not be invoked.  If it is invoked, it will be passed a single argument of a lua table that the Server_GameCustomMessage hook provided as a return value.
* '''HighlightTerritories''': A function that will highlight territories on the map, to alert the player about them.  Arguments:
# ''Array<[[Mod API Reference:TerritoryID|TerritoryID]]>>'': The IDs of the territories you wish to highlight.
* '''CreateLocatorCircle''': A function that will highlight an area of the map, to alert the player to it.  Pass an X,Y argument to determine the location.  You can get the coordinates of territories by looking at a [[Mod API Reference:TerritoryDetails|TerritoryDetails]] object. Arguments:
# ''Number'': The X coordinate.
# ''Number'': The Y coordinate.
[[Category:Mod API Reference]]

Latest revision as of 20:43, 7 November 2024


ClientGame: Provides information about a game in Client_ hooks. Also lets mods view and alter the orders list.

  • Map MapDetails: Details about the map for this game.
  • Us GamePlayer: Details about the player who is playing. Note that this will be nil when a spectator views this game, so be sure to test your mod as spectators if you use this field.
  • Game GameWL: Details about the game.
  • Map MapDetails: Details about the map for this game.
  • Settings GameSettings: The settings this game uses.
  • LatestStanding GameStanding: The latest state of the game.
  • GetDistributionStanding: A function used to get the GameStanding during the picking phase of this game. Pass this function your own callback function which takes a GameStanding as an argument. For example: game.GetDistributionStanding(function(standing) print('got ' .. standing) end). Your function will be called with nil if the distribution standing is not available, for example if it's an automatic distribution game. In the event of an error, such as lack of an internet connection, your callback will not be called and instead the player will get a "Could not connect" message.
  • GetStanding: A function used to get the GameStanding for any turn of the game. Pass this function three arguments: The first argument is an integer representing what turn to get (0 for the start of the game, 1 for the second turn, 2 for the third turn, etc.) The second argument is how many orders you want from that turn applied into the standing (specify 0 to get the start of the turn). Third, pass a callback function that will get called with the GameStanding. In the event of an error, such as lack of an internet connection, your callback will not be called and instead the player will get a "Could not connect" message.
  • GetTurn: A function used to get the GameTurn for any turn of the game. Identical to GetStanding in every way, except that it calls back your function with a GameTurn.
  • Orders Array<GameOrder>: Allows you to read and write the orders that the player is building up in the orders list for the current turn. You can call this property to see the orders, or assign a list of orders to it to replace the player's orders with your list.
  • CreateDialog: A function used to create a new dialog on the screen for players to interact with. Pass a single function callback as a argument to CreateDialog. Your function callback will be passed the same arguments as the the Client_PresentMenuUI hook, documented at Mod Hooks
  • SendGameCustomMessage: A function used to send a message to the server, which will be handled by the Server_GameCustomMessage hook as documented at Mod Hooks. Note that this message is rate-limited to 5 calls every 5 seconds per client to avoid extra tax on the server. Arguments:
  1. waitText: A string identifying what wait message will be displayed to the player as they're waiting for the server to reply.
  2. payload: Data that will be delivered to the Server_GameCustomMessage hook. Must be a lua table.
  3. callback: A function you provide which will be called back when the message is complete. If the message fails, such as due to a disconnected internet connection or an error in the server hook, this callback will not be invoked. If it is invoked, it will be passed a single argument of a lua table that the Server_GameCustomMessage hook provided as a return value.
  • HighlightTerritories: A function that will highlight territories on the map, to alert the player about them. Arguments:
  1. Array<TerritoryID>>: The IDs of the territories you wish to highlight.
  • CreateLocatorCircle: A function that will highlight an area of the map, to alert the player to it. Pass an X,Y argument to determine the location. You can get the coordinates of territories by looking at a TerritoryDetails object. Arguments:
  1. Number: The X coordinate.
  2. Number: The Y coordinate.