-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecc_exported_client.lua
346 lines (229 loc) · 9.2 KB
/
ecc_exported_client.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
---@param ctype string Type of the corona. Valid values are "simple", "directional", "nomat".
function createCustomCorona(x, y, z, rx, ry, rz, ctype, size, r, g, b, a, texture)
ctype = ctype or CORONA_TYPE_SIMPLE
if ctype ~= CORONA_TYPE_SIMPLE and ctype ~= CORONA_TYPE_DIRECTIONAL and ctype ~= CORONA_TYPE_NOMAT then
return warn("illegal corona type" ,2) and false
end
local dx, dy, dz = getDirectionFromRotation(rx or 0, ry or 0, rz or 0)
size = math.max(0, size or 1)
r = r and math.floor(math.clamp(r, 0, 255)) or 255
g = g and math.floor(math.clamp(g, 0, 255)) or 0
b = b and math.floor(math.clamp(b, 0, 255)) or 0
a = a and math.floor(math.clamp(a, 0, 255)) or 255
texture = texture or TEXTURE_DEFAULT
return ECC.create(ctype, texture, x, y, z, dx, dy, dz, size, r, g, b, a)
end
function getCustomCoronaType(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
return data.ctype
end
--- Doesn't affect "nomat" coronas
function setCustomCoronaTexture(corona, texture)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
texture = texture or TEXTURE_DEFAULT
if data.texture == texture then return false end
data.texture = texture
addEventHandler("onClientElementDestroy", texture, ECC.onTextureDestroy, false)
return true
end
function getCustomCoronaTexture(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
if data.texture == TEXTURE_DEFAULT then return nil end
return data.texture
end
function setCustomCoronaPosition(corona, x, y, z)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
if data.attachedTo then return false end
data.pos = {x, y, z}
return true
end
function getCustomCoronaPosition(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
return data.pos[1], data.pos[2], data.pos[3]
end
--- Affects only "directional" coronas
function setCustomCoronaRotation(corona, rotX, rotY, rotZ)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
if data.attachedTo then return false end
data.dir = {getDirectionFromRotation(rotX, rotY, rotZ)}
return true
end
function getCustomCoronaRotation(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
return getRotationFromDirection(data.dir[1], data.dir[2], data.dir[3])
end
function setCustomCoronaInterior(corona, int)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
if data.attachedTo then return false end
if data.int == int then return false end
data.int = math.clamp(math.floor(int), 0, 255)
return true
end
function getCustomCoronaInterior(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
return data.int
end
function setCustomCoronaDimension(corona, dim)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
if data.attachedTo then return false end
if data.dim == dim then return false end
data.dim = math.clamp(math.floor(dim), -1, 65535)
return true
end
function getCustomCoronaDimension(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
return data.dim
end
function attachCustomCorona(corona, attachedTo, offX, offY, offZ, offRotX, offRotY, offRotZ)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
data.offsets = {
offX or 0, offY or 0, offZ or 0,
getDirectionFromRotation(offRotX or 0, offRotY or 0, offRotZ or 0)
}
data.attachedTo = attachedTo
addEventHandler("onClientElementDestroy", attachedTo, ECC.onAttachedToDestroy, false)
return true
end
function detachCustomCorona(corona, element)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
if not data.attachedTo then return false end
element = element or data.attachedTo
if element ~= data.attachedTo then return false end
data.attachedTo = nil
return true
end
function getCustomCoronaAttachedTo(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
return data.attachedTo
end
function setCustomCoronaAttachedOffsets(corona, offX, offY, offZ, offRotX, offRotY, offRotZ)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
if not data.attachedTo then return false end
data.offsets = {
offX, offY, offZ,
getDirectionFromRotation(offRotX or 0, offRotY or 0, offRotZ or 0)
}
return true
end
function getCustomCoronaAttachedOffsets(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
if not data.attachedTo then return false end
local ox, oy, oz = data.offsets[1], data.offsets[2], data.offsets[3]
local orx, ory, orz = getRotationFromDirection(data.offsets[3], data.offsets[4], data.offsets[5])
return ox, oy, oz, orx, ory, orz
end
function setCustomCoronaSize(corona, size)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
size = math.max(0, size)
if data.size == size then return false end
data.size = size
return true
end
function getCustomCoronaSize(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
return data.size
end
function setCustomCoronaColor(corona, r, g, b, a)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
data.color[1] = math.floor(math.clamp(r, 0, 255))
data.color[2] = math.floor(math.clamp(g, 0, 255))
data.color[3] = math.floor(math.clamp(b, 0, 255))
data.color[4] = a and math.floor(math.clamp(a, 0, 255)) or data.color[4]
return true
end
function getCustomCoronaColor(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
return data.color[1], data.color[2], data.color[3], data.color[4]
end
function setCustomCoronaAlpha(corona, a)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
data.color[4] = math.floor(math.clamp(a, 0, 255))
return true
end
function getCustomCoronaAlpha(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
return data.color[4]
end
--- Affects only "directional" coronas.
--- Pass greater angles (180 is maximum)
---@param outerAngle number outer angle (0 - 180)
---@param innerAngle number inner angle (0 - outerAngle)
function setCustomCoronaLightCone(corona, outerAngle, innerAngle)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
if data.ctype ~= CORONA_TYPE_DIRECTIONAL then return false end
outerAngle = math.clamp(outerAngle, 0, 179)
innerAngle = math.clamp(innerAngle, 0, outerAngle)
data.lightCone = {
math.rad(outerAngle*0.5),
math.rad(innerAngle*0.5),
}
return true
end
function getCustomCoronaLightCone(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
if data.ctype ~= CORONA_TYPE_DIRECTIONAL then return nil end
return math.deg(data.lightCone[1]*2), math.deg(data.lightCone[2]*2)
end
--- Affects only "nomat" coronas
function setCustomCoronaLightAttenuationPower(corona, power)
local data = ECC.coronasData[corona]
if not data then error("bad argument #1 'corona' to 'setCustomCoronaLightAttenuationPower' (corona expected)", 2) end
if power and type(power) ~= "number" then error("bad argument #2 'power' to 'setCustomCoronaLightAttenuationPower' (number expected)", 2) end
if data.ctype ~= CORONA_TYPE_NOMAT then return false end
data.attenuationPower = math.max(0, power or LIGHT_ATTENUATION_POWER_DEFAULT)
return true
end
function getCustomCoronaLightAttenuationPower(corona)
local data = ECC.coronasData[corona]
if not data then error("bad argument #1 'corona' to 'getCustomCoronaLightAttenuationPower' (corona expected)", 2) end
if data.ctype ~= CORONA_TYPE_NOMAT then return nil end
return data.attenuationPower
end
function setCustomCoronaFadeDistance(corona, dist1, dist2)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
local fadeDist = {dist1 or FADE_DISTANCE_DEFAULT[1], dist2 or FADE_DISTANCE_DEFAULT[2]}
fadeDist[2] = math.min(fadeDist[1], fadeDist[2])
data.fadeDist = fadeDist
return true
end
function getCustomCoronaFadeDistance(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
return data.fadeDist[1], data.fadeDist[2]
end
function setCustomCoronaDepthBias(corona, depthBias)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
data.depthBias = math.clamp(depthBias or data.size, 0, data.size)
return true
end
function getCustomCoronaDepthBias(corona)
local data = ECC.coronasData[corona]
if not data then return warn("invalid corona", 2) and false end
return data.depthBias
end