IsCursorShowing: Difference between revisions
Jump to navigation
Jump to search
LordAzamath (talk | contribs) (added examples) |
No edit summary |
||
(5 intermediate revisions by 5 users not shown) | |||
Line 2: | Line 2: | ||
{{Server client function}} | {{Server client function}} | ||
This function is used to determine whether or not a player's cursor is showing. | This function is used to determine whether or not a player's cursor is showing. | ||
{{Note|This retrieves the cursor state that has been set using [[showCursor]], and thus doesn't take into account the cursor shown while the chatbox, menu or console are open. Also, keep in mind that while the client is aware of cursor states set from the server, the server doesn't know about cursor states set from the client.}} | |||
Note | |||
==Syntax== | ==Syntax== | ||
<section name="Server" class="server" show="true"> | <section name="Server" class="server" show="true"> | ||
Line 24: | Line 22: | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the player's cursor is showing, ''false'' if it isn't | Returns ''true'' if the player's cursor is showing, ''false'' if it isn't. | ||
</section> | </section> | ||
Line 49: | Line 47: | ||
And a more compact version | And a more compact version | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bindKey ("b", "down", -- binds B key to toggle cursor state | bindKey ("b", "down", -- binds B key to toggle cursor state | ||
function() | function() | ||
showCursor( not isCursorShowing() ) | showCursor( not isCursorShowing() ) | ||
end | end) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Line 59: | Line 57: | ||
==See Also== | ==See Also== | ||
{{Cursor_functions}} | {{Cursor_functions}} | ||
[[hu:isCursorShowing]] |
Revision as of 15:38, 27 August 2020
This function is used to determine whether or not a player's cursor is showing.
Note: This retrieves the cursor state that has been set using showCursor, and thus doesn't take into account the cursor shown while the chatbox, menu or console are open. Also, keep in mind that while the client is aware of cursor states set from the server, the server doesn't know about cursor states set from the client. |
Syntax
Click to collapse [-]
Serverbool isCursorShowing ( player thePlayer )
Required Arguments
- thePlayer: The player you want to get cursor state of.
Returns
Returns true if the player's cursor is showing, false if it isn't or if invalid parameters were passed.
Click to collapse [-]
Clientbool isCursorShowing ( )
Returns
Returns true if the player's cursor is showing, false if it isn't.
Example
Click to collapse [-]
ExampleThis serverside function toggles a player's cursor state.
function toggleCursor ( thePlayer ) local currentState = isCursorShowing ( thePlayer ) -- get the current cursor state as a boolean local oppositeState = not currentState -- get the new state as its logical opposite showCursor ( thePlayer, oppositeState ) -- set it as the new cursor state end
Click to collapse [-]
Clientside ExampleWith little of tweaking this can also be used clientside
function toggleCursor () local currentState = isCursorShowing () -- get the current cursor state as a boolean local oppositeState = not currentState -- get the new state as its logical opposite showCursor ( oppositeState ) -- set it as the new cursor state end
And a more compact version
bindKey ("b", "down", -- binds B key to toggle cursor state function() showCursor( not isCursorShowing() ) end)