Mod API Reference:Client DescribeOrder

From War.app Wiki
Revision as of 10:51, 2 November 2026 by Fizzer (talk | contribs) (Created page with "Put the function in a file named <code>Client_DescribeOrder.lua</code>: <pre> function Client_DescribeOrder(game, order, description) -- describe the order by calling functions on description end </pre> The client calls this hook when it shows one of your mod's orders in the orders list or in the turn history. Without it, the order's own text is shown, such as the <code>Message</code> the order was created with. Server hooks creat...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Put the function in a file named Client_DescribeOrder.lua:

function Client_DescribeOrder(game, order, description)
    -- describe the order by calling functions on description
end

The client calls this hook when it shows one of your mod's orders in the orders list or in the turn history. Without it, the order's own text is shown, such as the Message the order was created with.

Server hooks create events and custom orders with a fixed message. This hook lets your mod word that message for the player who is looking at it. For example, it can say "you" instead of a player's name, or show details that the message has no room for.

Argument Type Description
game ClientGame Information about the game.
order GameOrder The order being shown. Read-only.
description table The object you describe the order with. See below.

Both functions on description return description, so calls can be chained. Call them with a dot, not a colon.

  • description.SetText(text): replaces the order's text. Calling it again replaces what you set before. If you never call it, the order's own text is shown.
  • description.AddTooltipRow(text): adds a line to the order's tooltip. Your lines are shown above the tooltip the order would normally have. Up to 10 lines are shown; any more are ignored and a warning is written to the mod log.

Text is plain text and is cut to 200 characters.

The hook runs every time the order is displayed, so keep it quick. It should always give the same result for the same order. If the hook errors, the error is shown once. After that, the hook isn't called again until the game next refreshes, and the orders show their own text.

function Client_DescribeOrder(game, order, description)
    if (order.proxyType == 'GameOrderCustom') then
        description.SetText('Fortified ' .. game.Map.Territories[tonumber(order.Payload)].Name)
            .AddTooltipRow('Fortified territories get +3 defense until the end of the next turn');
    end
end