ExperimentalGear/scripts/common/util.lua

26 lines
626 B
Lua
Raw Normal View History

local function areaOverlap(x, y, areaX, areaY, areaW, areaH)
return x > areaX and y > areaY and x < areaX + areaW and y < areaY + areaH
end
--modulo operation for index value
local function modIndex(index, mod)
return (index - 1) % mod + 1
end
local function firstAlphaNum(s)
for i = 1, string.len(s) do
local byte = string.byte(s, i);
if ((byte >= 65 and byte <= 90) or (byte >= 97 and byte <= 122) or (byte >= 48 and byte <= 57)) then
return string.sub(s, i, i);
end
end
return '';
end
return {
areaOverlap = areaOverlap,
modIndex = modIndex,
firstAlphaNum = firstAlphaNum,
}