-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.lua
107 lines (95 loc) · 2.13 KB
/
Utils.lua
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
function has_value(tab, val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end
function tLen(T)
local count = 0
if T ~= nil then
for _ in pairs(T) do
count = count + 1
end
return count
end
return 0
end
function tprint(tbl, indent)
print("\n=======================")
if not tbl then
print("Nil table")
return
end
if not indent then
indent = 0
end
for k, v in pairs(tbl) do
formatting = string.rep(" ", indent) .. k .. ": "
if type(v) == "table" then
print(formatting)
tprint(v, indent + 1)
elseif type(v) == 'boolean' then
print(formatting .. tostring(v))
else
print(formatting .. v)
end
end
print("=======================")
end
function getAllEarnings(tbl)
if not tbl then
print("Nil table")
return
end
for k, v in pairs(tbl) do
if type(v) == "table" then
getAllEarnings(v)
else
if k == "earning" then
earning = earning + v
end
end
end
return earning
end
function getEarnings(tb1)
earning = 0
getAllEarnings(tb1, 0)
return earning
end
function setCasModels(tbl)
local id = nil
local x = nil
local y = nil
if not tbl then
print("Nil table")
return
end
for k, v in pairs(tbl) do
if type(v) == "table" then
setCasModels(v)
else
if k == "model_ID" then
id = v
print("trovo id")
end
if k == "x" then
x = v
print("trovo x")
end
if k == "y" then
y = v
print("trovo y")
end
if x ~= nil and y ~= nil and id ~= nil then
print("piazzo e resetto")
stratmap.objects.setModel (x, y, id, id)
x = nil
y = nil
id = nil
end
end
end
end