GetCursorPos: Difference between revisions

From The Official Visionaire Studio: Adventure Game Engine Wiki
No edit summary
No edit summary
Line 17: Line 17:
Example:
Example:
<syntaxhighlight>
<syntaxhighlight>
-- let's store the current position in a variable!
-- let's store the current position into a variable!
local variableName = getCursorPos()
local curPos = getCursorPos()


-- let's check if the stored cursor position equals another x,y value!
-- let's check if the stored cursor position equals another x,y value!
if variableName.x == 200 and variableName.y == 400 then
if curPos.x == 200 and curPos.y == 400 then
  -- do some action!
  -- do some action!
else
else

Revision as of 15:37, 12 March 2013

Command History

Available since v?


Stores the current position (absolute) of the mouse cursor into an x,y table, which can be used in a query to check if the current position is over an object/character or a certain part of the scene etc.


Syntax:

getCursorPos()


Example:

-- let's store the current position into a variable!
local curPos = getCursorPos()

-- let's check if the stored cursor position equals another x,y value!
if curPos.x == 200 and curPos.y == 400 then
 -- do some action!
else
 -- do some other action!
end


Arguments

none


Flags

none


Return

pos
Table containing x,y values of current mouse cursor position


Relevant Pages: setCursorPos