GetPlayerBrain

From Data Realms Wiki

(Difference between revisions)
Jump to: navigation, search
 
Line 5: Line 5:
|description          = Returns current brain for specified player.
|description          = Returns current brain for specified player.
|codedesc            = Finds any brains that belongs to the active human players. The pointer returned by GetPlayerBrain is not guaranteed to be safe to access so check it with MovableMan:IsActor before using it.
|codedesc            = Finds any brains that belongs to the active human players. The pointer returned by GetPlayerBrain is not guaranteed to be safe to access so check it with MovableMan:IsActor before using it.
-
|code                = <code lua n>for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
+
|code                = <code lua n>local Activ = ActivityMan:GetActivity()
 +
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
if Activ:PlayerActive(player) then
if Activ:PlayerActive(player) then
local Brain = Activ:GetPlayerBrain(player)
local Brain = Activ:GetPlayerBrain(player)

Latest revision as of 15:41, 1 June 2011

Function
SyntaxGetPlayerBrain( (number) Team )
Description:
Returns current brain for specified player.
ReturnsActor




Example
DescriptionFinds any brains that belongs to the active human players. The pointer returned by GetPlayerBrain is not guaranteed to be safe to access so check it with MovableMan:IsActor before using it.
Code
  1. local Activ = ActivityMan:GetActivity()
  2. for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
  3.         if Activ:PlayerActive(player) then
  4.                 local Brain = Activ:GetPlayerBrain(player)
  5.                 if Brain and MovableMan:IsActor(Brain) then
  6.                         print("Player #" .. player .. " has a brain")
  7.                 end
  8.         end
  9. end
OutputPrints the player number of any active brain that belongs to a human player.
Personal tools