GetPlayerBrain

From Data Realms Wiki

(Difference between revisions)
Jump to: navigation, search
m (Removed stub tag.)
 
(One intermediate revision not shown)
Line 4: Line 4:
|returns              = [[Actor]]  
|returns              = [[Actor]]  
|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.
 +
|code                = <code lua n>local Activ = ActivityMan:GetActivity()
 +
for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
 +
if Activ:PlayerActive(player) then
 +
local Brain = Activ:GetPlayerBrain(player)
 +
if Brain and MovableMan:IsActor(Brain) then
 +
print("Player #" .. player .. " has a brain")
 +
end
 +
end
 +
end</code>
 +
|output              = Prints the player number of any active brain that belongs to a human 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