Trigger API Reference\DCEI Functions\Player
int GetPlayerCount()
int GetPlayerCount()
Description
Returns the number of players in the game.
Example Usage
local player_count = DCEI.GetPlayerCount()
DCEI.LogMessage(player_count)
int GetCurrentPlayerId()
int GetCurrentPlayerId()
Description
Get the current player's id. Only useful in multiplayer.
Example Usage
local player_team_id = DCEI.GetPlayerTeamId(1)
if player_team_id = 1 then
DCEI.SetPlayerTeamId(1, 2)
end
void SetPlayerTeamId(int playerId, int teamId)
void SetPlayerTeamId(int playerId, int teamId)
Description
Used to set a player's team id.
Parameters
- int
playerId
the ID of the player to be switched. - int
teamId
the ID of the player's new team.
Example Usage
local player_team_id = DCEI.GetPlayerTeamId(1)
if player_team_id = 1 then
DCEI.SetPlayerTeamId(1, 2)
end
int GetPlayerTeamId(int playerId)
int GetPlayerTeamId(int playerId)
Description
Parameters
- int
playerId
the ID of the player.
Example Usage
local player_id = DCEI.GetCurrentPlayerId()
local player_team_id = DCEI.GetPlayerTeamId(player_id)
void AddGold(int playerId, int amount)
void AddGold(int playerId, int amount)
Description
Adds gold to a player. Maximum gold value for a player is 2,147,483,647 (2^31-1).
Parameters
- int
playerId
the ID of the player. - int
amount
the amount of gold to be added. Use negative values to subtract gold.
Example Usage
function OnRegionEnter()
DCEI.AddGold(1, 10)
end
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), DCEI.RegionAny, OnRegionEnter)
Related
void AddGoldAsync(int playerId, int amount)
void AddGoldAsync(int playerId, int amount)
Description
Adds a specified amount of gold to the player. Primarily used for Wild Sky; as most other games implement custom currencies via Lua rather than use the hard-coded engine gold currency. Maximum gold value for a player is 2,147,483,647 (2^31-1).
Parameters
- int
playerId
the ID of the player. - int
amount
the amount of gold to be added. Use negative values to subtract gold.
Example Usage
function OnRegionEnter()
DCEI.AddGold(1, 10)
end
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), DCEI.RegionAny, OnRegionEnter)
void SetGold(int playerId, int amount)
void SetGold(int playerId, int amount)
Description
Sets a player's gold value. Maximum gold value for a player is 2,147,483,647 (2^31-1).
Parameters
- int
playerId
the ID of the player. - int
amount
the amount of gold to be set.
Example Usage
function OnRegionEnter()
DCEI.SetGold(1, 10)
end
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), DCEI.RegionAny, OnRegionEnter)
Related
void SetGoldAsync(int playerId, int amount)
void SetGoldAsync(int playerId, int amount)
Description
Sets a player's gold value. Maximum gold value for a player is 2,147,483,647 (2^31-1).
Parameters
- int
playerId
the ID of the player. - int
amount
the amount of gold to be set.
Example Usage
function OnRegionEnter()
DCEI.SetGold(1, 10)
end
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), DCEI.RegionAny, OnRegionEnter)
int GetGold(int playerId)
int GetGold(int playerId)
Description
Returns a player's gold value.
Parameters
- int
playerId
the ID of the player.
Example Usage
function OnRegionEnter()
local player_gold = DCEI.GetGold(1)
if (player_gold + 10) > 2147483647 then
DCEI.SetGold(1, 2147483647)
else
DCEI.AddGold(1, 10)
end
end
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), DCEI.RegionAny, OnRegionEnter)
Related
int GetUnitPlayerId(unit unit)
int GetUnitPlayerId(unit unit)
Description
Returns the player ID of the owner of a unit.
Parameters
- unit
unit
the unit to return the player ID of.
Example Usage
local region = DCEI.FindRegion("region_0")
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
DCEI.LogMessage("Unit's Player ID: " .. DCEI.GetUnitPlayerId(unit))
int GetUnitTeamId(unit unit)
int GetUnitTeamId(unit unit)
Description
Returns the team ID of a unit.
Parameters
- unit
unit
the unit to return the team ID of.
Example Usage
local region = DCEI.FindRegion("region_0")
local team_id = 1
local player_id = 1
local unit_type = "DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
DCEI.LogMessage("Unit Team ID: " .. DCEI.GetUnitTeamId(unit))
object GetPlayerDeckCards()
object GetPlayerDeckCards()
Description
Wild Sky specific. Returns a lua table of the equipped cards from the meta.
Example Usage
local deck = DCEI.GetPlayerDeckCards()
Core.Util.LogDump(deck)