GetPlayerBrain

From Data Realms Wiki

(Difference between revisions)
Jump to: navigation, search
m (Removed stub tag.)
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>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.
|}}
|}}

Revision as of 09:05, 27 May 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. for player = Activity.PLAYER_1, Activity.MAXPLAYERCOUNT - 1 do
  2.         if Activ:PlayerActive(player) then
  3.                 local Brain = Activ:GetPlayerBrain(player)
  4.                 if Brain and MovableMan:IsActor(Brain) then
  5.                         print("Player #" .. player .. " has a brain")
  6.                 end
  7.         end
  8. end
OutputPrints the player number of any active brain that belongs to a human player.
Personal tools