Player.AddNotification (Civ5 API)

From Civilization Modding Wiki
Jump to navigationJump to search

This page is a part of the Lua and UI Reference (Civ5).


Function.png This function is a member of Player.

This is an instance method, invoke it with a colon.


Triggers a notification for a Player. Notifications appear as icons on the right side of the screen.


Usage

void Player:AddNotification(NotificationType notificationType, string description, string title, int x = -1, int y = -1, PlayerID extra1 = -1, int extra2 = -1)


Parameters

notificationType: No description available.
description: The text displayed when mousing over the icon
title: The text displayed (temporarily) next to the icon
x: X coordinate of relevant plot; use -1 if notification is not tied to a specific location
y: Y coordinate of relevant plot; use -1 if notification is not tied to a specific location
extra1: Optional additional information needed by some notification types
extra2: Optional additional information needed by some notification types


Examples

local pPlayer = Players[Game.GetActivePlayer()]
local pCity = pPlayer:GetCapitalCity()
local sTitle = "Plague strikes " .. pCity:GetName()
local sText = pCity:GetName() .. " is suffering from plague; population has been decreased"
pPlayer:AddNotification(NotificationTypes.NOTIFICATION_STARVING, sText, sTitle, pCity:GetX(), pCity:GetY())


Source code samples

TurnsRemaining.lua - DLC_02 DLC

DLC/DLC_02/Scenarios/NewWorldScenario/TurnsRemaining.lua
0224
player:AddNotification(NotificationTypes.NOTIFICATION_GENERIC, text, heading);
0422
pPlayer:AddNotification(NotificationTypes.NOTIFICATION_GENERIC, text, heading);


TurnsRemaining.lua (G&K)

DLC/Expansion/Scenarios/SteampunkScenario/TurnsRemaining.lua
0365
pActivePlayer:AddNotification(NotificationTypes.NOTIFICATION_GENERIC, sMessage, sSummary, -1, -1, iNewOwner);



The initial version of this page was created by the Civ5 API Bot, see the Civ5 API Reference FAQ. Some of the texts come from the 2kgames' wiki and most of code samples are copyrighted to Firaxis.
Functions' signatures were either copied from the 2kgames' wiki, or infered from the Lua source files and the binaries. Errors are possible.
Contributors may find help in the Contributors guide to the Civ5 API.