GetCursorPosition: Difference between revisions
Jump to navigation
Jump to search
Hell Demon (talk | contribs) |
mNo edit summary |
||
| Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
float float float float float getCursorPosition ( ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 12: | Line 12: | ||
===Returns=== | ===Returns=== | ||
Returns 5 values: cursorX, cursorY, worldX, worldY, worldZ. The first two values are the 2D screen coordinates of the cursor | Returns 5 values: cursorX, cursorY, worldX, worldY, worldZ. The first two values are the 2D relative screen coordinates of the cursor: cursorX goes from 0 (left side of the screen) to 1 (right side), cursurY goes from 0 (top) to 1 (bottom). The 3 values that follow are the 3D world map coordinates that the cursor points at. | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function cursorInfo() | function cursorInfo() | ||
screenx, screeny, worldx, worldy, worldz = getCursorPosition() | local screenx, screeny, worldx, worldy, worldz = getCursorPosition() | ||
outputChatBox("Cursor screen position: X=" .. screenx .. " Y=" .. screeny) | outputChatBox("Cursor screen position: X=" .. screenx .. " Y=" .. screeny) | ||
outputChatBox("Cursor world position: X=" .. worldx .. " Y=" .. worldy .. " Z=" .. worldz) | outputChatBox("Cursor world position: X=" .. worldx .. " Y=" .. worldy .. " Z=" .. worldz) | ||
Revision as of 14:42, 24 March 2008
This function gets the current position of the mouse cursor.
Syntax
float float float float float getCursorPosition ( )
Required Arguments
None
Returns
Returns 5 values: cursorX, cursorY, worldX, worldY, worldZ. The first two values are the 2D relative screen coordinates of the cursor: cursorX goes from 0 (left side of the screen) to 1 (right side), cursurY goes from 0 (top) to 1 (bottom). The 3 values that follow are the 3D world map coordinates that the cursor points at.
Example
function cursorInfo()
local screenx, screeny, worldx, worldy, worldz = getCursorPosition()
outputChatBox("Cursor screen position: X=" .. screenx .. " Y=" .. screeny)
outputChatBox("Cursor world position: X=" .. worldx .. " Y=" .. worldy .. " Z=" .. worldz)
end
See Also
- getAnalogControlState
- getBoundKeys
- getCommandsBoundToKey
- getKeyBoundToCommand
- getKeyState
- isCapsLockEnabled
- setAnalogControlState
- Shared
- addCommandHandler
- bindKey
- executeCommandHandler
- getCommandHandlers
- getFunctionsBoundToKey
- getKeyBoundToFunction
- isControlEnabled
- removeCommandHandler
- toggleAllControls
- toggleControl
- unbindKey