Player Functions
Contents
KillPlayer()
[require Xmoto >= 0.2.1]
Explanation
If you call this function, the players die. It's interesting if you want the players be killed by an enemy for example.
Script example
In the following example, the player will die when he will enter in the zone Zone0.
Zone0 = {} function Zone0.OnEnter() Game.KillPlayer() end
KillAPlayer(player)
[require Xmoto >= 0.3.0]
Explanation
If you call this function, a player dies. It's interesting if you want the player be killed by an enemy for example.
Script example
function OnLoad() Game.KillAPlayer(0) return true end
WinPlayer()
[require Xmoto >= 0.2.1]
Explanation
If you call this function, all players win the game (even if there are remaining strawberries).
Script example
In the following example, the player win on entering in the zone Zone0.
Zone0 = {} function Zone0.OnEnter() Game.WinPlayer() end
WinAPlayer(player)
[require Xmoto >= 0.3.0]
Explanation
If you call this function, a player wins the game (even if there are remaining strawberries).
Script example
function OnLoad() Game.WinAPlayer(0) return true end
NumberOfPlayers()
[require Xmoto >= 0.3.0]
Explanation
This function returns the number of players (dead or in live) in the level
Script example
function OnLoad() Game.Message(Game.NumberOfPlayers().." players") return true end
AddForceToPlayer(forceX, forceY, startTime, endTime, player)
[require Xmoto >= 0.4.2]
Explanation
This function apply an external force on the player player. The force will apply from startTime to endTime or will be infinite if endTime is 0. startTime and endTime are expressed in hundreaths and are relativ to the call function time. The force applied will be of (forceX, forceY). Application point is the center of the biker. In the example, a force will be applied to all players from time 5 to 10 seconds. Force is expressed in newton, mg/s-2 (meter * gramm / (seconds * seconds)).
Script example
function OnLoad() for i=0,Game.NumberOfPlayers()-1 do Game.Message("Kicking player "..(i+1)) Game.AddForceToPlayer(0, 1000, 500, 1000, i) end return true end