A new version of the mod framework was just released! This adds a bunch of new stuff mods can take advantage of:
1. Menu buttons. Mods can now subscribe to the Client_PresentMenuUI hook to get themselves a button on a game's menu. When the player clicks the button on the menu, the hook is invoked and a dialog can be shown on the screen.
2. New UI functions, UI.Alert and UI.PromptFromList let you show messages or ask questions of the player.
3. Mods can now read or write to the player's orders list on the client side. For example, a mod can create attacks or deploy orders or play cards for a player in their orders list. Of course, a player can always choose to delete, re-arrange, or otherwise manipulate those orders before committing. Mods can also read a game's entire history.
4. A new order, called GameOrderCustom, was added. By itself this order doesn't do anything, but mods can use it to send data up to the server. For example, client-side mod UI can create a custom order and place it the orders list, then the same mod can see that order server-side and take action.
5. Mods can now destroy UI they previously created by calling UI.Destroy() and passing a UI element.
I have written a new example mod to show off these new capabilities, the gift armies mod! This mod allows you to give armies to another player. You specify the territory you'd like to take armies from, who you want to give armies to, and when the turn advances it moves those armies to random territories belonging to the target player. Here's the code:
https://github.com/FizzerWL/ExampleMods/tree/master/GiftArmiesModHere's the rest of the changelog for today's update:
- If a mod puts a special unit owned by one player onto a territory owned by another, it no longer gives errors and the information tooltip now shows the owner. It also won't show the special unit as movable in the attack/transfer dialog to the territory owner.
- The multi-player page's membership gift now advertises Unity+mods.
- Added the mod function UI.PromptFromList to allow mods to ask the player to select an item out of a list of choices.
- Added the mod function UI.Alert so that mods can pop up simple messages.
- Fixed a bug with mods that made GameOrderPlayCard instances not return card-specific data. Thanks to TBest for reporting this.
- Fixed a bug with mods that caused an error when a mod hooked StartGame and the game was started by the host removing a player.
- Fixed a bug with mods that made the Armies.Add and Armies.Subtract functions not callable.
- Fixed a bug that could cause an error in multi-attack games with commanders. Thanks to kevin#1 for reporting this.
- Fixed a bug that caused an error if a multi-player game advanced to the next turn just as you were loading it.