Difference between revisions of "Player Functions"
(→GetPlayerPosition()) |
(→GetPlayerProfileName()) |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
+ | = Script Player Functions = | ||
+ | |||
+ | |||
+ | == GetPlayerProfileName() == | ||
+ | [*deprecated* -- cannot be used anymore] | ||
+ | === Explanation === | ||
+ | This function returns a string with the players profile name. | ||
+ | |||
+ | === Script Example === | ||
+ | This example prints the players profile name on level start. | ||
+ | |||
+ | function OnLoad() | ||
+ | name = Game.GetPlayerProfileName() | ||
+ | Game.Message(name) | ||
+ | return true | ||
+ | end | ||
+ | |||
== SetPlayerPosition(x, y, bRight) == | == SetPlayerPosition(x, y, bRight) == | ||
=== Explanation === | === Explanation === | ||
Line 11: | Line 28: | ||
Game.SetPlayerPosition(5, 0, 1) | Game.SetPlayerPosition(5, 0, 1) | ||
end | end | ||
+ | |||
== SetAPlayerPosition(x, y, bRight, player) == | == SetAPlayerPosition(x, y, bRight, player) == | ||
Line 23: | Line 41: | ||
return true | return true | ||
end | end | ||
+ | |||
== GetPlayerPosition() == | == GetPlayerPosition() == | ||
Line 43: | Line 62: | ||
== GetPlayerVelocity(player) == | == GetPlayerVelocity(player) == | ||
+ | [require Xmoto >= 0.5.0] | ||
+ | |||
=== Explanation === | === Explanation === | ||
Return the velocity of the player. | Return the velocity of the player. | ||
Line 58: | Line 79: | ||
Game.Message("Angle: "..Game.GetPlayerAngle(0)) | Game.Message("Angle: "..Game.GetPlayerAngle(0)) | ||
end | end | ||
+ | |||
== GetPlayerSpeed(player) == | == GetPlayerSpeed(player) == | ||
+ | [require Xmoto >= 0.5.0] | ||
+ | |||
=== Explanation === | === Explanation === | ||
Return the speed of the player. | Return the speed of the player. | ||
Line 75: | Line 99: | ||
Game.Message("Angle: "..Game.GetPlayerAngle(0)) | Game.Message("Angle: "..Game.GetPlayerAngle(0)) | ||
end | end | ||
+ | |||
== GetPlayerAngle(player) == | == GetPlayerAngle(player) == | ||
+ | [require Xmoto >= 0.5.0] | ||
+ | |||
=== Explanation === | === Explanation === | ||
Return the angle of the player. | Return the angle of the player. | ||
Line 92: | Line 119: | ||
Game.Message("Angle: "..Game.GetPlayerAngle(0)) | Game.Message("Angle: "..Game.GetPlayerAngle(0)) | ||
end | end | ||
+ | |||
== GetAPlayerPosition(player) == | == GetAPlayerPosition(player) == |
Latest revision as of 22:06, 5 January 2011
Contents
- 1 Script Player Functions
- 1.1 GetPlayerProfileName()
- 1.2 SetPlayerPosition(x, y, bRight)
- 1.3 SetAPlayerPosition(x, y, bRight, player)
- 1.4 GetPlayerPosition()
- 1.5 GetPlayerVelocity(player)
- 1.6 GetPlayerSpeed(player)
- 1.7 GetPlayerAngle(player)
- 1.8 GetAPlayerPosition(player)
- 1.9 KillPlayer()
- 1.10 KillAPlayer(player)
- 1.11 WinPlayer()
- 1.12 WinAPlayer(player)
Script Player Functions
GetPlayerProfileName()
[*deprecated* -- cannot be used anymore]
Explanation
This function returns a string with the players profile name.
Script Example
This example prints the players profile name on level start.
function OnLoad() name = Game.GetPlayerProfileName() Game.Message(name) return true end
SetPlayerPosition(x, y, bRight)
Explanation
Set the position and direction of the players in the game. bRight can be 0 or 1.
Script example
The example teleports the playerq each time one enters the zone.
Zone0 = {} function Zone0.OnEnter() Game.SetPlayerPosition(5, 0, 1) end
SetAPlayerPosition(x, y, bRight, player)
Explanation
Set the position and direction of the player in the game. bRight can be 0 or 1.
Script example
The example show how to teleport the player 0 at start of the level to the position (20, 5)
function OnLoad() Game.SetAPlayerPosition(20, 5, 1, 0) return true end
GetPlayerPosition()
Explanation
Return the triplet (x, y, bRight) which give the position of the player 0 in the game.
Script example
This example make the player unable to get the strawberry ;-)
function Tick() x, y, bright = Game.GetPlayerPosition() if x > 18 then Game.SetPlayerPosition(5, 0, 1) end return true end
GetPlayerVelocity(player)
[require Xmoto >= 0.5.0]
Explanation
Return the velocity of the player.
Script example
This example show informations when the player pressed the key M.
function OnLoad() Game.SetKeyHook("M", "Infos") return true end function Infos() Game.Message("Velocity: "..Game.GetPlayerVelocity(0)) Game.Message("Speed: "..Game.GetPlayerSpeed(0)) Game.Message("Angle: "..Game.GetPlayerAngle(0)) end
GetPlayerSpeed(player)
[require Xmoto >= 0.5.0]
Explanation
Return the speed of the player.
Script example
This example show informations when the player pressed the key M.
function OnLoad() Game.SetKeyHook("M", "Infos") return true end function Infos() Game.Message("Velocity: "..Game.GetPlayerVelocity(0)) Game.Message("Speed: "..Game.GetPlayerSpeed(0)) Game.Message("Angle: "..Game.GetPlayerAngle(0)) end
GetPlayerAngle(player)
[require Xmoto >= 0.5.0]
Explanation
Return the angle of the player.
Script example
This example show informations when the player pressed the key M.
function OnLoad() Game.SetKeyHook("M", "Infos") return true end function Infos() Game.Message("Velocity: "..Game.GetPlayerVelocity(0)) Game.Message("Speed: "..Game.GetPlayerSpeed(0)) Game.Message("Angle: "..Game.GetPlayerAngle(0)) end
GetAPlayerPosition(player)
[require Xmoto >= 0.3.0]
Explanation
Return the triplet (x, y, bRight) which give the position of a player in the game.
Script example
function OnLoad() x, y, bright = Game.GetAPlayerPosition(0) Game.Message("Player0 position is ("..x..","..y..")") return true end
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