-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.lua
More file actions
58 lines (49 loc) · 1.04 KB
/
Copy pathtools.lua
File metadata and controls
58 lines (49 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
-- File of tools for project Ulysse.B
-- Like !boolean in C#
function inverseBool( bool )
if(bool) then
return false
else
return true
end
end
function split(s, delimiter)
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
return result;
end
-- Input is Table of boolean and return number of variable on true
function getNumOfTrue( b )
local cpt = 0
for i=1,#b do
if(b[i]) then
cpt = cpt +1
end
end
return cpt
end
-- convert position pixel to case
function getCooCase( obj , sizex , sizey )
local obj = {}
obj.x = obj.x / sizex
obj.y = obj.y / sizey
return obj
end
function round(num)
under = math.floor(num)
upper = math.floor(num) + 1
underV = -(under - num)
upperV = upper - num
if (upperV > underV) then
return under
else
return upper
end
end
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end