Skip to content

isCursorShowing

Type: Shared

This function determines the state of a player's cursor.

This example creates a function to set the state of the player's cursor using the showCursor function.

isCursorShowing-3.lua
function toggleCursor()
local cursorState = isCursorShowing() -- Retrieve the state of the player's cursor
local cursorStateOpposite = not cursorState -- The logical opposite of the cursor state
showCursor(cursorStateOpposite) -- Setting the new cursor state
end

If you are already advanced in scripting, using this code is recommended, as it is much more compact:

isCursorShowing-4.lua
function toggleCursor()
showCursor(not isCursorShowing())
end

This example creates a function that allows the player to change the state of the cursor using the showCursor and bindKey functions.

isCursorShowing-5.lua
function toggleCursor()
local cursorState = isCursorShowing() -- Retrieve the state of the player's cursor
local cursorStateOpposite = not cursorState -- The logical opposite of the cursor state
showCursor(cursorStateOpposite) -- Setting the new cursor state
end
bindKey("m", "down", toggleCursor) -- Assigning our toggleCursor function to the 'm' key press.

If you are already advanced in scripting, using this code is recommended, as it is much more compact:

isCursorShowing-6.lua
bindKey("m", "down",
function()
showCursor(not isCursorShowing())
end
)