er2.getPlayer 7
Find a reference to the Soldier controlled by the player
Return value
Return Type | Description |
---|---|
Soldier | Reference to the Soldier controlled by the player. Null if any |
No parameters defined for this function.
Examples
-- get a reference to the soldier controlled by the player
local player = er2.getPlayer()
--print name of the soldier controller by the player
print("Player's name: "..player.getName())
--prepare a condition to wait for the player being not null (so to spawn or choose a soldier to control)
local condition1 = function() return not (er2:getPlayer() == nil) end
-- wait for the condition of soldier being spawned
waitUntil(condition1 )
--done!
print("Player has spawned!")