Skip to content

Commit 3cfa65b

Browse files
committed
Add client Cursor functions
This is a first draft for functions and the schema.
1 parent c98cea3 commit 3cfa65b

27 files changed

+364
-0
lines changed

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"redhat.vscode-yaml"
4+
]
5+
}

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"yaml.schemas": {
3+
"schemas/function.yaml": "/functions/**/*"
4+
}
5+
}

articles/.gitkeep

Whitespace-only changes.

assets/setCursorAlpha.jpg

9.96 KB
Loading

elements/.gitkeep

Whitespace-only changes.

events/.gitkeep

Whitespace-only changes.

functions/.gitkeep

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- 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
9+
end
10+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function cursorInfo()
2+
if isCursorShowing() then -- if the cursor is showing
3+
local screenx, screeny, worldx, worldy, worldz = getCursorPosition()
4+
5+
outputChatBox( string.format( "Cursor screen position (relative): X=%.4f Y=%.4f", screenx, screeny ) ) -- make the accuracy of floats 4 decimals
6+
outputChatBox( string.format( "Cursor world position: X=%.4f Y=%.4f Z=%.4f", worldx, worldy, worldz ) ) -- make the accuracy of floats 4 decimals accurate
7+
else
8+
outputChatBox( "Your cursor is not showing." )
9+
end
10+
end
11+
addCommandHandler( "cursorpos", cursorInfo )
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
addEventHandler( "onClientRender", root,
2+
function()
3+
if isCursorShowing() then
4+
local screenx, screeny, worldx, worldy, worldz = getCursorPosition()
5+
local px, py, pz = getCameraMatrix()
6+
local hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, worldx, worldy, worldz )
7+
8+
if hit then
9+
dxDrawText( "Cursor at " .. x .. " " .. y .. " " .. z, 200, 200 )
10+
if elementHit then
11+
dxDrawText( "Hit element " .. getElementType(elementHit), 200, 220 )
12+
end
13+
end
14+
end
15+
end
16+
)

0 commit comments

Comments
 (0)