Mod API Reference: Difference between revisions
m Fixed GameOrderCustom reference |
No edit summary |
||
Line 117: | Line 117: | ||
* [[Mod API Reference:TerritoryModification|TerritoryModification]] | * [[Mod API Reference:TerritoryModification|TerritoryModification]] | ||
* [[Mod API Reference:TerritoryStanding|TerritoryStanding]] | * [[Mod API Reference:TerritoryStanding|TerritoryStanding]] | ||
* [[Mod API Reference:TickCount|TickCount]] | |||
* [[Mod API Reference:UI|UI]] | * [[Mod API Reference:UI|UI]] | ||
[[Category:Mod Developers Guide]][[Category:Mod API Reference]] | [[Category:Mod Developers Guide]][[Category:Mod API Reference]] |
Revision as of 15:47, 6 June 2023
This explains how to use Warzone's mod API and links to the documentation for each object type.
Types
When writing a mod, you'll encounter variables/objects of three basic types:
- Primitives: strings, numbers, booleans, etc.
- Tables: collections of key/value pairs. A table is a lot like a hashmap or dictionary in other languages. Note that in Warzone, the key of a table will always be either a string or an integer. Some places in this reference will refer to Arrays which are just tables with numeric keys starting at 1.
- Proxy objects: Discussed in the next section.
Proxy Objects
A proxy object proxies information back and forth between your mod and Warzone. You can tell if an object is a proxy object by looking for a proxyType
field. All proxy objects always have the following fields:
- proxyType: A string identifying the type of proxy object.
- readOnly: False if you're allowed to make changes to this proxy object, or true if it's read-only.
- readableKeys: An array containing all fields you're allowed to read from this object.
- writableKeys: An array containing all fields you're allowed to change on this object if readOnly is False.
To read a field, simply read it like a property: obj.field
. Similarly, to write to a proxy object, just assign to that field: obj.field = newVal
.
Here's a handy function you can include in your mod to print out everything on a proxy object:
function PrintProxyInfo(obj) print('type=' .. obj.proxyType .. ' readOnly=' .. tostring(obj.readonly) .. ' readableKeys=' .. table.concat(obj.readableKeys, ',') .. ' writableKeys=' .. table.concat(obj.writableKeys, ',')); end
Writing Tables
If a writable Warzone proxy object exposes a table, and you wish to make changes to that table, you must assign the table back to the proxy object. For example, assume you have a GameStanding
object named standing
which exposes the Cards
table, and you want to add something at index 9:
standing.Cards[9] = something --WRONG!
This code won't work since the proxy object isn't having anything assigned to it. Proxy objects are only aware of changes when something is directly assigned into them. To make this work, you must assign the table into the proxy object's field:
local cards = standing.Cards cards[9] = something standing.Cards = cards; --Right
Note: If you use lua's type
function, proxy objects will identify themselves as tables. However, that should be considered an implementation detail. For the purposes of this wiki, proxy objects aren't considered tables.
API Reference
- ActiveCard
- ActiveCardWoreOff
- Armies
- BonusDetails
- Boss1
- Boss2
- Boss3
- Boss4
- CardGame
- CardGameAbandon
- CardGameAirlift
- CardGameBlockade
- CardGameBomb
- CardGameDiplomacy
- CardGameGift
- CardGameOrderDelay
- CardGameOrderPriority
- CardGameReconnaissance
- CardGameReinforcement
- CardGameSanctions
- CardGameSpy
- CardGameSurveillance
- CardInstance
- ClanPlayerInfo
- ClientGame
- Commander
- CustomScenario
- CustomScenarioTerritory
- DistributionMode
- Game
- GameColor
- GameOpenSeat
- GameOrder
- GameOrderAttackTransfer
- GameOrderAttackTransferResult
- GameOrderBossEvent
- GameOrderCustom
- GameOrderDeploy
- GameOrderDiscard
- GameOrderEvent
- GameOrderPlayCard
- GameOrderPlayCardAbandon
- GameOrderPlayCardAirlift
- GameOrderPlayCardAirliftResult
- GameOrderPlayCardBlockade
- GameOrderPlayCardBomb
- GameOrderPlayCardDiplomacy
- GameOrderPlayCardFogged
- GameOrderPlayCardGift
- GameOrderPlayCardOrderDelay
- GameOrderPlayCardOrderPriority
- GameOrderPlayCardReconnaissance
- GameOrderPlayCardReinforcement
- GameOrderPlayCardSanctions
- GameOrderPlayCardSpy
- GameOrderPlayCardSurveillance
- GameOrderReceiveCard
- GameOrderStateTransition
- GamePlayer
- GameSettings
- GameStanding
- GameWL
- IncomeMod
- IsVersionOrHigher
- MapDetails
- MapFamily
- NoParameterCardInstance
- PendingStateTransition
- PlayerCards
- PlayerInfo2
- ReinforcementCardInstance
- ServerGame
- SpecialUnit
- TerritoryConnection
- TerritoryDetails
- TerritoryModification
- TerritoryStanding
- TickCount
- UI