Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit d00da27

Browse files
committed
Added GetPlayerController lua binding
1 parent 1619060 commit d00da27

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,8 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
635635

636636
- Added `Controller` control state `PIE_MENU_OPENED` that is true for the first Update in which the `PieMenu` is opened.
637637

638+
- Added `Activity` Lua function `GetPlayerController`, which gets you the `Controller` used for GUI stuff and when there's no `Actor` selected in an `Activity`. Be aware, it's very likely possible to cause problems by doing dumb things with this.
639+
638640
</details>
639641

640642
<details><summary><b>Changed</b></summary>

Entities/Activity.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ namespace RTE {
363363
/// </summary>
364364
/// <param name="player">The player to reset the message timer for.</param>
365365
void ResetMessageTimer(int player = 0) { if (player >= Players::PlayerOne && player < Players::MaxPlayerCount) { m_MessageTimer[player].Reset(); } }
366+
367+
/// <summary>
368+
/// Gets a pointer to the GUI controller of the specified player.
369+
/// </summary>
370+
/// <param name="player">Which player to get the Controller of.</param>
371+
/// <returns>A pointer to the player's Controller. Ownership is NOT transferred!</returns>
372+
Controller * GetPlayerController(int player = 0) { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? &m_PlayerController[player] : nullptr; }
366373
#pragma endregion
367374

368375
#pragma region Team Handling
@@ -629,7 +636,7 @@ namespace RTE {
629636
/// </summary>
630637
/// <param name="player">Which player to get the controlled actor of.</param>
631638
/// <returns>A pointer to the controlled Actor. Ownership is NOT transferred! 0 If no actor is currently controlled by this player.</returns>
632-
Actor * GetControlledActor(int player = 0) { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? m_ControlledActor[player] : 0; }
639+
Actor * GetControlledActor(int player = 0) { return (player >= Players::PlayerOne && player < Players::MaxPlayerCount) ? m_ControlledActor[player] : nullptr; }
633640

634641
/// <summary>
635642
/// Makes the player's ControlledActor the leader of any squad it is a member of.

Lua/LuaBindingsActivities.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ namespace RTE {
4343
.def("HumanBrainCount", &Activity::HumanBrainCount)
4444
.def("AIBrainCount", &Activity::AIBrainCount)
4545
.def("GetControlledActor", &Activity::GetControlledActor)
46+
.def("GetPlayerController", &Activity::GetPlayerController)
4647
.def("SetTeamFunds", &Activity::SetTeamFunds)
4748
.def("GetTeamFunds", &Activity::GetTeamFunds)
4849
.def("SetTeamAISkill", &Activity::SetTeamAISkill)

0 commit comments

Comments
 (0)