blob: 054210f32b5460e0528459f337bf18d9e6b07490 (
plain)
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
|
ch_core.open_submod("hotbar")
function ch_core.predmety_na_liste(player, jako_pole)
local result = {}
if not player then
return result
end
local inv = player:get_inventory()
if not inv then
return result
end
local hotbar = inv:get_list("main")
if not hotbar then
return result
end
local hotbar_length = player:hud_get_hotbar_itemcount()
if not hotbar_length then
hotbar_length = 8
elseif hotbar_length > 32 then
hotbar_length = 32
elseif hotbar_length < 1 then
hotbar_length = 1
end
if jako_pole then
for i = 1, hotbar_length, 1 do
local name = hotbar[i]:get_name()
if name and name ~= "" then
local t = result[name]
if t then
table.insert(t, i)
else
result[name] = {i}
end
end
end
else
for i = hotbar_length, 1, -1 do
local name = hotbar[i]:get_name()
if name and name ~= "" then
result[name] = i
end
end
end
return result
end
ch_core.close_submod("hotbar")
|