Skip to content

Commit 27c22ff

Browse files
committed
Cursor functions
1 parent 4f72c67 commit 27c22ff

17 files changed

+78
-129
lines changed
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
-- Simple command to test the getCursorAlpha function
2-
addCommandHandler( "cursorAlpha",
3-
function ()
4-
if ( isCursorShowing ( ) ) then
5-
outputChatBox( "The cursor alpha: "..getCursorAlpha( ) )
6-
else
7-
outputChatBox( "The cursor is not showing!" )
8-
end
2+
addCommandHandler("cursorAlpha", function()
3+
if (isCursorShowing()) then
4+
outputChatBox("The cursor alpha: " .. getCursorAlpha())
5+
else
6+
outputChatBox("The cursor is not showing!")
97
end
10-
)
8+
end)

functions/Cursor/examples/getCursorAlpha.lua

Lines changed: 0 additions & 10 deletions
This file was deleted.

functions/Cursor/examples/getCursorPosition-1.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ function cursorInfo()
55
local screenx, screeny, worldx, worldy, worldz = getCursorPosition()
66

77
-- make the accuracy of floats 4 decimals and print to chatbox
8-
outputChatBox( string.format( "Cursor screen position (relative): X=%.4f Y=%.4f", screenx, screeny ) )
9-
outputChatBox( string.format( "Cursor world position: X=%.4f Y=%.4f Z=%.4f", worldx, worldy, worldz ) )
8+
outputChatBox(string.format("Cursor screen position (relative): X=%.4f Y=%.4f",screenx, screeny))
9+
outputChatBox(string.format("Cursor world position: X=%.4f Y=%.4f Z=%.4f", worldx,worldy, worldz))
1010
else
11-
outputChatBox( "Your cursor is not showing." )
11+
outputChatBox("Your cursor is not showing.")
1212
end
1313
end
14-
addCommandHandler( "cursorpos", cursorInfo )
14+
addCommandHandler("cursorpos", cursorInfo)

functions/Cursor/examples/getCursorPosition-2.lua

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
bindKey("m", "down",
2-
function()
3-
showCursor(not isCursorShowing())
4-
end
5-
)
1+
bindKey("m", "down", function()
2+
showCursor(not isCursorShowing())
3+
end)
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
-- Simple command to test the setCursorAlpha function
2-
addCommandHandler( "cursorAlpha",
3-
function ()
4-
-- Show the cursor if it is not showing or hide the cursor if it is
5-
showCursor( not isCursorShowing ( ) )
6-
-- Set the alpha to 100
7-
setCursorAlpha(100)
8-
end
9-
)
2+
addCommandHandler("cursorAlpha", function()
3+
-- Show the cursor if it is not showing or hide the cursor if it is
4+
showCursor(not isCursorShowing())
5+
-- Set the alpha to 100
6+
setCursorAlpha(100)
7+
end)
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
addCommandHandler( "cursoralpha",
2-
function ()
3-
-- Show the cursor if it is not showing or hide the cursor if it is
4-
showCursor( not isCursorShowing ( ) )
5-
6-
-- Set the alpha to 100
7-
setCursorAlpha(100)
8-
end
9-
)
1+
addCommandHandler("cursoralpha", function()
2+
-- Show the cursor if it is not showing or hide the cursor if it is
3+
showCursor(not isCursorShowing())
4+
5+
-- Set the alpha to 100
6+
setCursorAlpha(100)
7+
end)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
function centerCursorFunction()
2-
local showing = isCursorShowing ()
2+
local showing = isCursorShowing()
33
if showing then -- if the cursor is showing
4-
local screenX, screenY = guiGetScreenSize () --get the screen size in pixels
5-
setCursorPosition (screenX/2, screenY/2) --set the cursor position to the center of the screen
4+
local screenX, screenY = guiGetScreenSize() -- get the screen size in pixels
5+
setCursorPosition(screenX / 2, screenY / 2) -- set the cursor position to the center of the screen
66
else
7-
outputChatBox( "Your cursor is not showing." )
7+
outputChatBox("Your cursor is not showing.")
88
end
99
end
10-
addCommandHandler( "cursorpos", centerCursorFunction )
10+
addCommandHandler("cursorpos", centerCursorFunction)
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
function centerCursorFunction()
22
-- is cursor showing?
33
if isCursorShowing() then
4-
--get the screen size in pixels
5-
local screenX, screenY = guiGetScreenSize ()
4+
-- get the screen size in pixels
5+
local screenX, screenY = guiGetScreenSize()
66

7-
--set the cursor position to the center of the screen
8-
setCursorPosition (screenX/2, screenY/2)
7+
-- set the cursor position to the center of the screen
8+
setCursorPosition(screenX / 2, screenY / 2)
99
else
10-
outputChatBox( "Your cursor is not showing." )
10+
outputChatBox("Your cursor is not showing.")
1111
end
1212
end
13-
addCommandHandler( "cursorpos", centerCursorFunction )
13+
addCommandHandler("cursorpos", centerCursorFunction)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
local thePlayer = getPlayerFromName ( "Dave" ) -- get the player named Dave
2-
if thePlayer then -- if we got him
3-
showCursor ( thePlayer, true ) -- make his cursor show
4-
if isCursorShowing ( thePlayer ) then -- did it show?
5-
outputChatBox ( "Cursor is now showing for Dave." ) -- print a message to the chat box
1+
local thePlayer = getPlayerFromName("Dave") -- get the player named Dave
2+
if thePlayer then -- if we got him
3+
showCursor(thePlayer, true) -- make his cursor show
4+
if isCursorShowing(thePlayer) then -- did it show?
5+
outputChatBox("Cursor is now showing for Dave.") -- print a message to the chat box
66
end
77
end

0 commit comments

Comments
 (0)