Add EmmyLua annotations to utility functions
This commit is contained in:
parent
147c1a2f69
commit
fb64a26414
12
script.lua
12
script.lua
@ -5,7 +5,9 @@ TEXTURE_WIDTH = 128
|
|||||||
TEXTURE_HEIGHT = 128
|
TEXTURE_HEIGHT = 128
|
||||||
|
|
||||||
-- utility functions -- {{{
|
-- utility functions -- {{{
|
||||||
--- dump table --
|
|
||||||
|
--- Create a string representation of a table
|
||||||
|
--- @param o table
|
||||||
function dumpTable(o)
|
function dumpTable(o)
|
||||||
if type(o) == 'table' then
|
if type(o) == 'table' then
|
||||||
local s = '{ '
|
local s = '{ '
|
||||||
@ -19,6 +21,7 @@ function dumpTable(o)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param uv table
|
||||||
function UV(uv)
|
function UV(uv)
|
||||||
return vectors.of({
|
return vectors.of({
|
||||||
uv[1]/TEXTURE_WIDTH,
|
uv[1]/TEXTURE_WIDTH,
|
||||||
@ -27,6 +30,8 @@ function UV(uv)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param inputstr string
|
||||||
|
---@param sep string
|
||||||
function splitstring (inputstr, sep)
|
function splitstring (inputstr, sep)
|
||||||
if sep == nil then
|
if sep == nil then
|
||||||
sep = "%s"
|
sep = "%s"
|
||||||
@ -38,6 +43,7 @@ function splitstring (inputstr, sep)
|
|||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param input string
|
||||||
function unstring(input)
|
function unstring(input)
|
||||||
if input=="nil" then
|
if input=="nil" then
|
||||||
return nil
|
return nil
|
||||||
@ -50,6 +56,8 @@ function unstring(input)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param func function
|
||||||
|
---@param table table
|
||||||
function map(func, table)
|
function map(func, table)
|
||||||
local t={}
|
local t={}
|
||||||
for k, v in pairs(table) do
|
for k, v in pairs(table) do
|
||||||
@ -58,6 +66,8 @@ function map(func, table)
|
|||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param func function
|
||||||
|
---@param table table
|
||||||
function filter(func, table)
|
function filter(func, table)
|
||||||
local t={}
|
local t={}
|
||||||
for k, v in pairs(table) do
|
for k, v in pairs(table) do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user