-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLineDrawer.ttslua
More file actions
614 lines (552 loc) · 22.3 KB
/
LineDrawer.ttslua
File metadata and controls
614 lines (552 loc) · 22.3 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
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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
--[[
Line Drawer
Made by Sionar
--]]
------------------Constants
VERSION = '1.2.3 Unofficial'
COLOR_TABLE = {'White', 'Brown', 'Red', 'Orange', 'Yellow', 'Green', 'Teal', 'Blue', 'Purple', 'Pink'}
X_OFF = 1.2
PLAYER1_POS = {{-1.4+X_OFF*0,0.1,0.7}, {-1.4+X_OFF*0,0.1,1.1}, {-2.0+X_OFF*0,0.1,1.1}, {-2.0+X_OFF*0,0.1,0.7}, {-2.0+X_OFF*0,0.1,0.3}, {-2.0+X_OFF*0,0.1,-0.1}, {-2.0+X_OFF*0,0.1,-0.5}, {-1.4+X_OFF*0,0.1,-0.5}, {-1.4+X_OFF*0,0.1,-0.1}, {-1.4+X_OFF*0,0.1,0.3}}
PLAYER2_POS = {{-1.4+X_OFF*1,0.1,0.7}, {-1.4+X_OFF*1,0.1,1.1}, {-2.0+X_OFF*1,0.1,1.1}, {-2.0+X_OFF*1,0.1,0.7}, {-2.0+X_OFF*1,0.1,0.3}, {-2.0+X_OFF*1,0.1,-0.1}, {-2.0+X_OFF*1,0.1,-0.5}, {-1.4+X_OFF*1,0.1,-0.5}, {-1.4+X_OFF*1,0.1,-0.1}, {-1.4+X_OFF*1,0.1,0.3}}
COLOR_POS = {{-1.4+X_OFF*2,0.1,0.7}, {-1.4+X_OFF*2,0.1,1.1}, {-2.0+X_OFF*2,0.1,1.1}, {-2.0+X_OFF*2,0.1,0.7}, {-2.0+X_OFF*2,0.1,0.3}, {-2.0+X_OFF*2,0.1,-0.1}, {-2.0+X_OFF*2,0.1,-0.5}, {-1.4+X_OFF*2,0.1,-0.5}, {-1.4+X_OFF*2,0.1,-0.1}, {-1.4+X_OFF*2,0.1,0.3}}
GIVE_TOOL_BUTTON_POS = {{1,0.1,0.9}, {0,0.1,0.9}, {-1,0.1,0.9}, {-1.7,0.1,0.3}, {-1.7,0.1,-0.3}, {-1,0.1,-0.9}, {0,0.1,-0.9}, {1,0.1,-0.9}, {1.7,0.1,-0.3}, {1.7,0.1,0.3}}
LINE_HEIGHT = 1
POINTS =
{
White = {29.3, LINE_HEIGHT, -26},
Brown = {0, LINE_HEIGHT, -26},
Red = {-29.3, LINE_HEIGHT, -26},
Orange = {-44, LINE_HEIGHT, -11.73},
Yellow = {-44, LINE_HEIGHT, 11.73},
Green = {-29.3, LINE_HEIGHT, 26},
Teal = {0, LINE_HEIGHT, 26},
Blue = {29.3, LINE_HEIGHT, 26},
Purple = {44, LINE_HEIGHT, 11.73},
Pink = {44, LINE_HEIGHT, -11.73},
}
VALUE =
{
White = 0,
Brown = 1,
Red = 2,
Orange = 3,
Yellow = 4,
Green = 5,
Teal = 6,
Blue = 7,
Purple = 8,
Pink = 9
}
GROUP =
{
White = 0,
Brown = 0,
Red = 0,
Orange = 1,
Yellow = 1,
Green = 2,
Teal = 2,
Blue = 2,
Purple = 3,
Pink = 3
}
LINE_SPACING = 1
HEIGHT_SPACING = 0.2
------------------Variables
nameLabels = {}
valLabels = {}
lineTable = {}
player1 = ''
player2 = ''
lineColor = ''
promOnly = false
style = 'block'
------------------Functions
function onLoad(saveString)
if not (saveString == '') then
local save = JSON.decode(saveString)
lineTable = save['lt']
style = save['s']
promOnly = save['p']
end
refreshButtons()
self.setDescription('v ' .. VERSION .. '\nMade by Sionar')
end
function onSave()
local save = {}
save['lt'] = lineTable
save['s'] = style
save['p'] = promOnly
local saveString = JSON.encode(save)
return saveString
end
function addLineStraight(pColor1, pColor2, lColor)
for k,v in pairs(lineTable) do
if v.player1 == pColor1 and v.player2 == pColor2 or v.player1 == pColor2 and v.player2 == pColor1 then
return
end
end
if pColor1 == '' or pColor2 == '' or lColor == '' then
return
end
local point1 = POINTS[pColor1]
local point2 = POINTS[pColor2]
if (pColor1 == 'White' and pColor2 == 'Red') or (pColor1 == 'Red' and pColor2 == 'White') then
point1 = {point1[1],point1[2],point1[3]+0.5}
point2 = {point2[1],point2[2],point2[3]+0.5}
end
if (pColor1 == 'Green' and pColor2 == 'Blue') or (pColor1 == 'Blue' and pColor2 == 'Green') then
point1 = {point1[1],point1[2],point1[3]-0.5}
point2 = {point2[1],point2[2],point2[3]-0.5}
end
addSegment(pColor1, pColor2, point1, point2, lColor)
end
function addLineBlock(pColor1, pColor2, lColor)
for k,v in pairs(lineTable) do
if v.player1 == pColor1 and v.player2 == pColor2 or v.player1 == pColor2 and v.player2 == pColor1 then
return
end
end
if pColor1 == '' or pColor2 == '' or lColor == '' then
return
end
local point1 = POINTS[pColor1]
local point2 = POINTS[pColor2]
local point3 = nil
local point4 = nil
local pColor1Offset = VALUE[pColor2] - VALUE[pColor1] - 5
if pColor1Offset <= -6 then
pColor1Offset = pColor1Offset + 10
end
pColor2Offset = -1 * pColor1Offset
if GROUP[pColor1] == 0 then
point1 = {point1[1] + pColor1Offset * LINE_SPACING,point1[2],point1[3]}
elseif GROUP[pColor1] == 1 then
point1 = {point1[1],point1[2],point1[3] - pColor1Offset * LINE_SPACING}
elseif GROUP[pColor1] == 2 then
point1 = {point1[1] - pColor1Offset * LINE_SPACING,point1[2],point1[3]}
elseif GROUP[pColor1] == 3 then
point1 = {point1[1],point1[2],point1[3] + pColor1Offset * LINE_SPACING}
end
if GROUP[pColor2] == 0 then
point2 = {point2[1] + pColor2Offset * LINE_SPACING,point2[2],point2[3]}
elseif GROUP[pColor2] == 1 then
point2 = {point2[1],point2[2],point2[3] - pColor2Offset * LINE_SPACING}
elseif GROUP[pColor2] == 2 then
point2 = {point2[1] - pColor2Offset * LINE_SPACING,point2[2],point2[3]}
elseif GROUP[pColor2] == 3 then
point2 = {point2[1],point2[2],point2[3] + pColor2Offset * LINE_SPACING}
end
if GROUP[pColor1] == GROUP[pColor2] then --Same side of table
if GROUP[pColor1] == 0 then
if pColor1 == 'Brown' or pColor2 == 'Brown' then
point3 = {point1[1], LINE_HEIGHT, point1[3]+8}
point4 = {point2[1], LINE_HEIGHT, point2[3]+8}
else
point3 = {point1[1], LINE_HEIGHT, point1[3]+9}
point4 = {point2[1], LINE_HEIGHT, point2[3]+9}
end
elseif GROUP[pColor1] == 2 then
if pColor1 == 'Teal' or pColor2 == 'Teal' then
point3 = {point1[1], LINE_HEIGHT, point1[3]-8}
point4 = {point2[1], LINE_HEIGHT, point2[3]-8}
else
point3 = {point1[1], LINE_HEIGHT, point1[3]-9}
point4 = {point2[1], LINE_HEIGHT, point2[3]-9}
end
elseif GROUP[pColor1] == 1 then
point3 = {point1[1] + 8, LINE_HEIGHT, point1[3]}
point4 = {point2[1] + 8, LINE_HEIGHT, point2[3]}
else
point3 = {point1[1] - 8, LINE_HEIGHT, point1[3]}
point4 = {point2[1] - 8, LINE_HEIGHT, point2[3]}
end
addSegment(pColor1, pColor2, point1, point3, lColor)
addSegment(pColor1, pColor2, point3, point4, lColor)
addSegment(pColor1, pColor2, point4, point2, lColor)
elseif GROUP[pColor1] % 2 == GROUP[pColor2] % 2 then --Opposite sides of table
if (pColor1 == 'White' and pColor2 == 'Blue') or --Directly facing each other
(pColor1 == 'Blue' and pColor2 == 'White') or
(pColor1 == 'Brown' and pColor2 == 'Teal') or
(pColor1 == 'Teal' and pColor2 == 'Brown') or
(pColor1 == 'Red' and pColor2 == 'Green') or
(pColor1 == 'Green' and pColor2 == 'Red') or
(pColor1 == 'Yellow' and pColor2 == 'Purple') or
(pColor1 == 'Purple' and pColor2 == 'Yellow') or
(pColor1 == 'Orange' and pColor2 == 'Pink') or
(pColor1 == 'Pink' and pColor2 == 'Orange') then
addSegment(pColor1, pColor2, point1, point2, lColor)
else
if pColor1 == 'White' or pColor2 == 'White' then
point3 = {point1[1], LINE_HEIGHT + HEIGHT_SPACING * 0, 0}
point4 = {point2[1], LINE_HEIGHT + HEIGHT_SPACING * 0, 0}
elseif pColor1 == 'Brown' or pColor2 == 'Brown' then
point3 = {point1[1], LINE_HEIGHT + HEIGHT_SPACING * 1, 0}
point4 = {point2[1], LINE_HEIGHT + HEIGHT_SPACING * 1, 0}
elseif pColor1 == 'Red' or pColor2 == 'Red' then
point3 = {point1[1], LINE_HEIGHT + HEIGHT_SPACING * 2, 0}
point4 = {point2[1], LINE_HEIGHT + HEIGHT_SPACING * 2, 0}
elseif pColor1 == 'Orange' or pColor2 == 'Orange' then
point3 = {0, LINE_HEIGHT + HEIGHT_SPACING * 1, point1[3]}
point4 = {0, LINE_HEIGHT + HEIGHT_SPACING * 1, point2[3]}
elseif pColor1 == 'Yellow' or pColor2 == 'Yellow' then
point3 = {0, LINE_HEIGHT + HEIGHT_SPACING * 2, point1[3]}
point4 = {0, LINE_HEIGHT + HEIGHT_SPACING * 2, point2[3]}
end
addSegment(pColor1, pColor2, point1, point3, lColor)
addSegment(pColor1, pColor2, point3, point4, lColor)
addSegment(pColor1, pColor2, point4, point2, lColor)
end
else --Adjacent sides of table
if GROUP[pColor1] % 2 == 0 then
point3 = {point1[1], LINE_HEIGHT, point2[3]}
else
point3 = {point2[1], LINE_HEIGHT, point1[3]}
end
if pColor1 == 'White' or pColor2 == 'White' or pColor1 == 'Green' or pColor2 == 'Green' then
point3[2] = LINE_HEIGHT + HEIGHT_SPACING * 0
elseif pColor1 == 'Brown' or pColor2 == 'Brown' or pColor1 == 'Blue' or pColor2 == 'Blue' then
point3[2] = LINE_HEIGHT + HEIGHT_SPACING * 1
elseif pColor1 == 'Red' or pColor2 == 'Red' or pColor1 == 'Teal' or pColor2 == 'Teal' then
point3[2] = LINE_HEIGHT + HEIGHT_SPACING * 2
end
addSegment(pColor1, pColor2, point1, point3, lColor)
addSegment(pColor1, pColor2, point3, point2, lColor)
end
end
function addSegment(playerColor1, playerColor2, point1, point2, lineColor)
local lineData =
{
player1 = playerColor1,
player2 = playerColor2,
points = {point1, point2},
color = lineColor,
thickness = 0.5,
rotation = {0,0,0}
}
table.insert(lineTable, lineData)
end
function removeLine(playerColor1, playerColor2)
for i = #lineTable, 1, -1 do
if lineTable[i].player1 == playerColor1 and lineTable[i].player2 == playerColor2 or lineTable[i].player1 == playerColor2 and lineTable[i].player2 == playerColor1 then
table.remove(lineTable, i)
end
end
end
function drawLineFunc(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
if style == 'straight' then
addLineStraight(player1, player2, lineColor)
else
addLineBlock(player1, player2, lineColor)
end
Global.setVectorLines(lineTable)
clearUI()
end
end
function remLineFunc(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
removeLine(player1, player2)
Global.setVectorLines(lineTable)
clearUI()
end
end
function clearLinesFunc(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
lineTable = {}
Global.setVectorLines(lineTable)
clearUI()
end
end
function importFunc(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
local noteTakerNotes = Global.getTable('noteTakerNotes')
for i = 1, #noteTakerNotes do
if noteTakerNotes[i].conflict == '(Conflict)' or noteTakerNotes[i].conflict == '(Rev Con)' then
local p1, p2, lC
if noteTakerNotes[i].color1 ~= '' then
p1 = noteTakerNotes[i].color1
if noteTakerNotes[i].color2 == '' then
p2 = p1
else
p2 = noteTakerNotes[i].color2
end
if lineColor == '' then
lC = p1
else
lC = lineColor
end
if style == 'straight' then
addLineStraight(p1, p2, lC)
else
addLineBlock(p1, p2, lC)
end
end
end
end
Global.setVectorLines(lineTable)
clearUI()
end
end
function promStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
if promOnly == true then
promOnly = false
broadcastToAll("Line drawing tool access has been granted to all users", {1,1,1})
else
promOnly = true
broadcastToAll("Line drawing tool access has been granted to promoted users only", {1,1,1})
end
end
refreshButtons()
end
function styleStart(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
if style == 'block' then
style = 'straight'
broadcastToAll("Style has been changed to straight", {1,1,1})
else
style = 'block'
broadcastToAll("Style has been changed to block", {1,1,1})
end
end
refreshButtons()
end
------------------UI
function refreshButtons()
self.clearButtons()
createLabels()
createP1Buttons()
createP2Buttons()
createColorButtons()
createActionButtons()
end
function clearUI()
player1 = ''
player2 = ''
refreshButtons()
end
function createLabels()
local buttonParam = {label = 'Player 1', click_function = 'nulFunc', color = {0,0,0,1}, font_color = stringColorToRGB('White'), function_owner = self,
position = {-1.7,0.1,-1}, rotation = {0,0,0}, width = 1, height = 1, font_size = 120}
self.createButton(buttonParam)
local buttonParam = {label = 'Player 2', click_function = 'nulFunc', color = {0,0,0,1}, font_color = stringColorToRGB('White'), function_owner = self,
position = {-0.5,0.1,-1}, rotation = {0,0,0}, width = 1, height = 1, font_size = 120}
self.createButton(buttonParam)
local buttonParam = {label = 'Color', click_function = 'nulFunc', color = {0,0,0,1}, font_color = stringColorToRGB('White'), function_owner = self,
position = {0.7,0.1,-1}, rotation = {0,0,0}, width = 1, height = 1, font_size = 120}
self.createButton(buttonParam)
end
function createP1Buttons()
buttonParam = {}
for i = 1,10 do
buttonParam.click_function = 'setPlayer1-' .. i
buttonParam.label = COLOR_TABLE[i]
buttonParam.function_owner = self
buttonParam.position = PLAYER1_POS[i]
buttonParam.width = 300
buttonParam.font_color = stringColorToRGB(COLOR_TABLE[i])
buttonParam.font_size = 50
if player1 == COLOR_TABLE[i] then
buttonParam.color = stringColorToRGB(COLOR_TABLE[i])
else
buttonParam.color = {0,0,0,1}
end
self.createButton(buttonParam)
end
end
function setPlayer1(clickedButton, playerColor, index)
if Player[playerColor].admin or not promOnly then
if player1 == COLOR_TABLE[index] then
player1 = ''
else
player1 = COLOR_TABLE[index]
end
refreshButtons()
end
end
for k = 1,10 do
_G['setPlayer1-' .. k] = function(obj, col)
setPlayer1(obj, col, k)
end
end
function createP2Buttons()
buttonParam = {}
for i = 1,10 do
buttonParam.click_function = 'setPlayer2-' .. i
buttonParam.label = COLOR_TABLE[i]
buttonParam.function_owner = self
buttonParam.position = PLAYER2_POS[i]
buttonParam.width = 300
buttonParam.font_color = stringColorToRGB(COLOR_TABLE[i])
buttonParam.font_size = 50
if player2 == COLOR_TABLE[i] then
buttonParam.color = stringColorToRGB(COLOR_TABLE[i])
else
buttonParam.color = {0,0,0,1}
end
self.createButton(buttonParam)
end
end
function setPlayer2(clickedButton, playerColor, index)
if Player[playerColor].admin or not promOnly then
if player2 == COLOR_TABLE[index] then
player2 = ''
else
player2 = COLOR_TABLE[index]
end
refreshButtons()
end
end
for k = 1,10 do
_G['setPlayer2-' .. k] = function(obj, col)
setPlayer2(obj, col, k)
end
end
function createColorButtons()
buttonParam = {}
for i = 1,10 do
buttonParam.click_function = 'setLineColor' .. i
buttonParam.label = COLOR_TABLE[i]
buttonParam.function_owner = self
buttonParam.position = COLOR_POS[i]
buttonParam.width = 300
buttonParam.font_color = stringColorToRGB(COLOR_TABLE[i])
buttonParam.font_size = 50
if lineColor == COLOR_TABLE[i] then
buttonParam.color = stringColorToRGB(COLOR_TABLE[i])
else
buttonParam.color = {0,0,0,1}
end
self.createButton(buttonParam)
end
end
function setLineColor(clickedButton, playerColor, index)
if Player[playerColor].admin or not promOnly then
if lineColor == COLOR_TABLE[index] then
lineColor = ''
else
lineColor = COLOR_TABLE[index]
end
refreshButtons()
end
end
for k = 1,10 do
_G['setLineColor' .. k] = function(obj, col)
setLineColor(obj, col, k)
end
end
function createActionButtons()
local buttonParam = {click_function = 'drawLineFunc', label = "Draw\nLine", color = {1,1,1}, font_color = stringColorToRGB('Black'), function_owner = self,
position = {1.9,0.1,-0.7}, rotation = {0,0,0}, width = 500, height = 300, font_size = 80}
self.createButton(buttonParam)
local buttonParam = {click_function = 'remLineFunc', label = "Remove\nLine", color = {1,1,1}, font_color = stringColorToRGB('Black'), function_owner = self,
position = {1.9,0.1,-0.1}, rotation = {0,0,0}, width = 500, height = 300, font_size = 80}
self.createButton(buttonParam)
local buttonParam = {click_function = 'clearLinesFunc', label = "Clear\nAll Lines", color = {1,1,1}, font_color = stringColorToRGB('Black'), function_owner = self,
position = {1.9,0.1,0.5}, rotation = {0,0,0}, width = 500, height = 300, font_size = 80}
self.createButton(buttonParam)
local buttonParam = {click_function = 'importFunc', label = 'Import from\nNotetaker', color = {1,1,1}, font_color = stringColorToRGB('Black'), function_owner = self,
position = {1.9,0.1,1.1}, rotation = {0,0,0}, width = 500, height = 300, font_size = 80}
self.createButton(buttonParam)
local buttonParam = {click_function = 'styleStart', function_owner = self, label = '☆', color = {0,0,0,0.8}, font_color = stringColorToRGB('Blue'),
position = {1.6,0.1,-1.2}, width = 100, height = 100, font_size = 80, tooltip = 'Toggle Line Style'}
if style == 'block' then
buttonParam.label = '★'
end
self.createButton(buttonParam)
local buttonParam = {click_function = 'promStart', function_owner = self, label = '☆', color = {0,0,0,0.8}, font_color = stringColorToRGB('Green'),
position = {1.9,0.1,-1.2}, width = 100, height = 100, font_size = 80, tooltip = 'Toggle Promoted Only'}
if promOnly == true then
buttonParam.label = '★'
end
self.createButton(buttonParam)
local buttonParam = {click_function = 'givetMenu', function_owner = self, label = '☆', color = {0,0,0,0.8}, font_color = stringColorToRGB('Red'),
position = {2.2,0.1,-1.2}, width = 100, height = 100, font_size = 80, tooltip = 'Give Line\nDrawer to:'}
self.createButton(buttonParam)
end
function givetMenu()
self.clearButtons()
for i = 1,10 do
local buttonParam = {click_function = 'giveTool' .. i, label = COLOR_TABLE[i], color = stringColorToRGB(COLOR_TABLE[i]), function_owner = self,
position = GIVE_TOOL_BUTTON_POS[i], rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
end
local buttonParam = {click_function = 'returnFunc', label = "Cancel", color = {1,1,1,0.8}, function_owner = self,
position = {0,0.1,0}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
end
function giveTool(clickedButton, playerColor, index)
if Player[playerColor].admin or not promOnly then
self.setLock(true)
local tempScale = self.getScale()[1]
self.scale(1/tempScale)
self.scale(6.1)
local pos = {forward = -13, right = 0, up = 3}
local rot = {x = 0, y = 180, z = 0}
local options = Global.getTable('options')
if options.zoneType ~= 6 then
if COLOR_TABLE[index] == 'Purple' or COLOR_TABLE[index] == 'Orange' then
pos['right'] = 5
elseif COLOR_TABLE[index] == 'Pink' or COLOR_TABLE[index] == 'Yellow' then
pos['right'] = -5
end
end
giveObjectToPlayer(self, COLOR_TABLE[index], pos, rot)
refreshButtons()
end
end
for k = 1,10 do
_G['giveTool' .. k] = function(obj, col)
giveTool(obj, col, k)
end
end
function returnFunc(clickedButton, playerColor)
if Player[playerColor].admin or not promOnly then
refreshButtons()
end
end
function giveObjectToPlayer(object, playerColor, posAdd, rotAdd, ...)
local pos
local rot
local vForward
local vRight
local vUp
if playerColor == 'Maroon' or playerColor == 'Tan' then
local greyPlayerHandGuids = Global.getTable('greyPlayerHandGuids')
local ph = getObjectFromGUID(greyPlayerHandGuids[playerColor])
if ph then
pos = ph.getPosition()
pos = {x = pos['x'], y = pos['y'], z = pos['z'] - 2.26}
rot = ph.getRotation()
vForward = ph.getTransformForward()
vRight = ph.getTransformRight()
vUp = ph.getTransformUp()
end
else
local ph = Player[playerColor].getPlayerHand();
if ph then
pos = {x = ph['pos_x'], y = ph['pos_y'], z = ph['pos_z']}
rot = {x = ph['rot_x'], y = ph['rot_y'], z = ph['rot_z']}
vForward = {x = ph['trigger_forward_x'], y = ph['trigger_forward_y'], z = ph['trigger_forward_z']}
vRight = {x = ph['trigger_right_x'], y = ph['trigger_right_y'], z = ph['trigger_right_z']}
vUp = {x = ph['trigger_up_x'], y = ph['trigger_up_y'], z = ph['trigger_up_z']}
end
end
if pos then
if rotAdd['exactRot'] then
object.setRotationSmooth({rotAdd['x'], rotAdd['y'], rotAdd['z']}, ...)
else
object.setRotationSmooth({rot['x'] + rotAdd['x'], rot['y'] + rotAdd['y'], rot['z'] + rotAdd['z']}, ...)
end
if posAdd['forceHeight'] then
object.setPositionSmooth({pos['x'] + vForward['x'] * posAdd['forward'] + vRight['x'] * posAdd['right'] + vUp['x'] * posAdd['up'],
posAdd['forceHeight'],
pos['z'] + vForward['z'] * posAdd['forward'] + vRight['z'] * posAdd['right'] + vUp['z'] * posAdd['up']}, ...)
else
object.setPositionSmooth({pos['x'] + vForward['x'] * posAdd['forward'] + vRight['x'] * posAdd['right'] + vUp['x'] * posAdd['up'],
pos['y'] + vForward['y'] * posAdd['forward'] + vRight['y'] * posAdd['right'] + vUp['y'] * posAdd['up'],
pos['z'] + vForward['z'] * posAdd['forward'] + vRight['z'] * posAdd['right'] + vUp['z'] * posAdd['up']}, ...)
end
end
end