GetCameraTarget: Difference between revisions
Jump to navigation
Jump to search
Black Dragon (talk | contribs) No edit summary |
mNo edit summary |
||
(13 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | {{Server client function}} | ||
__NOTOC__ | |||
This function returns an [[element]] that corresponds to the current target of the specified player's camera (i.e. what it is following). | This function returns an [[element]] that corresponds to the current target of the specified player's camera (i.e. what it is following). | ||
==Syntax== | ==Syntax== | ||
<section class="server" name="Server" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
element getCameraTarget ( player thePlayer ) | element getCameraTarget ( player thePlayer ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[player]]:getCameraTarget|cameraTarget|setCameraTarget}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePlayer:''' The player whose camera you wish to receive the target of. | *'''thePlayer:''' The player whose camera you wish to receive the target of. | ||
</section> | |||
<section class="client" name="Client" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
element getCameraTarget () | |||
</syntaxhighlight> | |||
</section> | |||
===Returns=== | ===Returns=== | ||
Returns an [[element]] if the function was successful, ''false'' | * Returns an [[element]] of the target if the function was successful, or ''false'' if bad arguments were specified | ||
{{New feature|3|1.0| | |||
* Returns ''false'' if the camera is in Fixed mode and has no target. | |||
}} | |||
==Example== | ==Example== | ||
This example | This example checks whether a player's camera's target is another player, and returns true or false accordingly. | ||
<section class="server" name="Server script" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | function isTargetPlayer( thePlayer ) | ||
local target = getCameraTarget( | local target = getCameraTarget ( thePlayer ) | ||
if ( target ) then | if ( getElementType ( target ) == "player" ) then -- If target is a player | ||
return | return true -- Return true | ||
else | else | ||
return false | return false -- Otherwise, return false. | ||
end | end | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Camera functions}} | {{Camera functions}} | ||
[[hu:getCameraTarget]] | |||
[[RO:getCameraTarget]] |
Latest revision as of 08:08, 10 October 2020
This function returns an element that corresponds to the current target of the specified player's camera (i.e. what it is following).
Syntax
Click to collapse [-]
Serverelement getCameraTarget ( player thePlayer )
OOP Syntax Help! I don't understand this!
- Method: player:getCameraTarget(...)
- Variable: .cameraTarget
- Counterpart: setCameraTarget
Required Arguments
- thePlayer: The player whose camera you wish to receive the target of.
Click to collapse [-]
Clientelement getCameraTarget ()
Returns
- Returns an element of the target if the function was successful, or false if bad arguments were specified
- Returns false if the camera is in Fixed mode and has no target.
Example
This example checks whether a player's camera's target is another player, and returns true or false accordingly.
Click to collapse [-]
Server scriptfunction isTargetPlayer( thePlayer ) local target = getCameraTarget ( thePlayer ) if ( getElementType ( target ) == "player" ) then -- If target is a player return true -- Return true else return false -- Otherwise, return false. end end