CTP2 Bureau : SLIC Triggers
CTP2 Bureau
The Modding
Knowledgebase
Apolyton CTP2 forums
Apolyton CTP2 archives
Source Code Project SVN

SLIC Triggers

Triggers in old-style CTP1-format may still be used in CTP2 (including the AE) on UI components. Examples from AOM show that (1.) this works and (2.) it may be useful in order to display additional (game-/player-/civ-) information in the form of messages.

by BureauBert

SLIC Triggers on UI Components

From Joe Rumsey's SLIC 1.2 introduction:

There is also a special format for triggering by UI components:

Trigger 'name' on "UI Component Name" when (expression) {
commands
}

It behaves in the same way as the normal format, except that it is only evaluated when the UI component is used. The name follows the same rules as for message boxes. The body of the trigger is executed only when the expression is true (not equal to 0). A SLIC expression is a C-style mathematical expression. These are all valid expressions:

  • 1 + 1
  • a + b
  • a * (b + c)
  • (a * b) + c
  • a && b
  • a || b
  • a < b
  • a > 2
  • a <= b
  • a >= b
  • a != b
  • !a
  • (a && !b) || c

The variables used in the expression for a trigger determine when the trigger might be run. For example, if the built-in variable unit.built is used, the trigger condition will be checked whenever a unit is built. However, any given trigger is never placed in more than one list of triggers to be checked. So while a trigger whose only built-in variable in the conditional is g.player will be checked whenever a player's turn begins, one that uses both g.player and unit.built will only be checked when a unit is built. The author has tried to make the order of which variables takes precedence as logical as possible. Some variables make no sense when used in the same expression (E.G. city.built and unit.sighted can't be fired at the same time). In other cases, the list the trigger is added to should be the one that will fire more often.

Examples from AOM

trigger 'TSPDiplomacy' on "ControlPanelWindow.ControlPanel.ShortcutPad.FrenzyButton" when (1) 
{
    Message(g.player, 'FrenzyDiplomacy');
}

trigger 'TSPDiplomacy' on "ControlPanelWindow.ControlPanel.ShortcutPad.KingButton" when (1)
{
    Message(g.player, 'KingStatus');
}

trigger 'TSPDiplomacy' on "ControlPanelWindow.ControlPanel.ShortcutPad.RebelButton" when (1)
{
    Message(g.player, 'RiotB');
}

trigger 'TSPDiplomacy' on "ControlPanelWindow.ControlPanel.ShortcutPad.ResourceButton" when (1)
{
    Message(g.player, 'TradeA');
}
  Administration
This site is currently maintained by: BureauBert (Webmaster)  Maquiladora (Manager)  Legal Notice: Legal Notice Statistics: 87994 unique users since 02.05.2004 (» Site Statistics) Hosted by: WebhostOne
Share this page:  VK Facebook Twitter LiveJournal OK MR Google+ LinkedIn tumblr Pinterest Blogger Digg Evernote