-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpolyzone.lua
119 lines (106 loc) · 3.09 KB
/
polyzone.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
-- PS-Zones pretty much, credits goes to Project Sloth
local Zones = {}
local Combo = nil
local updateComboZone = function(zone)
if Combo == nil then
Combo = ComboZone:Create({zone}, {name="combo", debugPoly=false})
Zones[zone.name] = zone
else
Combo:AddZone(zone)
Zones[zone.name] = zone
end
end
local zoneExist = function(name)
if Zones[name] then
return true
else
return false
end
end
local destroyZone = function(name)
if not zoneExist(name) then return print("Zone doesn't exist") end
if Zones[name] then
Combo:RemoveZone(name)
Zones[name]:destroy()
Zones[name] = nil
end
end exports("destroyZone", destroyZone)
local getZoneInsideCoord = function (coords)
local list = {}
for i, zone in pairs(Zones) do
local isInside = zone:isPointInside(coords)
if isInside then
for _, option in pairs(zone.data) do
table.insert(list, option)
end
end
end
return list
end exports("getZoneInsideCoord", getZoneInsideCoord)
local createBoxZone = function (name, point, length, width, data)
if zoneExist(name) then
print('Replacing current zone with name: '..name)
destroyZone(name)
end
if not data then data = {} end
data.name = name
local box = BoxZone:Create(point, length, width, data)
updateComboZone(box)
end exports("createBoxZone", createBoxZone)
local createPolyZone = function (name, points, data)
if zoneExist(name) then
print('Replacing current zone with name: '..name)
destroyZone(name)
end
if not data then data = {} end
data.name = name
local poly = PolyZone:Create(points, data)
updateComboZone(poly)
end exports("createPolyZone", createPolyZone)
createPolyZone("test", {
vec2(1971.993, 3736.499),
vec2(1966.032, 3733.178),
vec2(1967.879, 3728.867),
vec2(1973.225, 3731.780)
}, {
data= {
{
label = "Test",
subItems = {
{
label = "Subitem",
subItems = {
{
label = "Subitem in a subitem 🤓"
}
}
}
}
}
},
name="test",
minZ=31.0,
maxZ=34.0,
debugGrid=true,
debugPoly=true,
})
local createCircleZone = function (name, point, radius, data)
if zoneExist(name) then
print('Replacing current zone with name: '..name)
destroyZone(name)
end
if not data then data = {} end
data.name = name
local circle = CircleZone:Create(point, radius, data)
updateComboZone(circle)
end exports("createCircleZone", createCircleZone)
local createEntityZone = function(name, entity, data)
if zoneExist(name) then
print('Replacing current zone with name: '..name)
destroyZone(name)
end
if not data then data = {} end
data.name = name
local entity = EntityZone:Create(entity, data)
updateComboZone(entity)
end exports("createEntityZone", createEntityZone)