Added lua-language-server annotations

This commit is contained in:
Alexey 2025-06-25 13:05:41 +03:00
commit c7d8fa4f8b
7 changed files with 151 additions and 87 deletions

View file

@ -1,21 +1,26 @@
-- Global config table
---@class Config
---@field pointRadius number Radius of each grid point
---@field linePointRadius number Radius of line start/end point
---@field cellSize number Size of each grid cell
---@field lineStyle string love2d line style setting
---@field lineWidth number love2d line width setting
---@field dragSensivity number drag sensivity, px
Config = {
-- Radius of each grid point
pointRadius = 7,
-- Radius of line start/end point
linePointRadius = 10,
-- Size of each grid cell
cellSize = 30,
-- love2d line drawing settings
lineStyle = "smooth",
lineWidth = 5,
-- drag sensivity, px
dragSensivity = 5
}
-- Colors table
---@enum Color
Color = {
white = { 1, 1, 1 },
red = { 1, 0, 0 },
@ -24,7 +29,11 @@ Color = {
}
-- Find key by value in table by predicate
function tableFind( table, value, pred )
---@param table table
---@param value any
---@param pred function
---@return any
function TableFind( table, value, pred )
for key, innervalue in pairs( table ) do
if pred( value, innervalue ) then
return key
@ -34,8 +43,12 @@ function tableFind( table, value, pred )
end
-- Find if value exists in table by predicate
function tableHas( table, value, pred )
for key, innervalue in pairs( table ) do
---@param table table
---@param value any
---@param pred function
---@return boolean
function TableHas( table, value, pred )
for _, innervalue in pairs( table ) do
if pred( value, innervalue ) then
return true
end