er2.getPlayer 41

Find a reference to the Soldier controlled by the player


Return value

Return TypeDescription
SoldierReference to the Soldier controlled by the player. Null if any

No parameters defined for this function.


Examples

Example 14

-- 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())

Example 15

--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!")

Back to Scripting API