-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtarot-cards.lua
More file actions
1720 lines (1648 loc) · 60.5 KB
/
tarot-cards.lua
File metadata and controls
1720 lines (1648 loc) · 60.5 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
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Created By, Hiram Abiff v2.1
--[[
This script was only possible due to the continued help from the really
cool guys on the Berserk Forums. There may be some pieces of code that don't
belong, but I will be sure to clean it up over time.
A lot of snippets you may find here, are directly from MrStumps lua tutorials;
I gratly thank him for his help and patience with providing others the
knowledge to create their own scripts.
If you have any suggestions on further changes or if you find any bugs, please
make a post in the comments or "Bugs" discussions thread for this mod. Thank you.
For a complete list of changes for v2.1, you can read the changelog located on the
workshop page for this mod.
]]
--------------------------------------------------------
local debug = false
function onLoad()
local backgColor = {0,0,0}--{0.3,0.2,0}
local fontColor = {1,1,1}
self.createButton({ -- index 0, Previous Layout
label="<--", click_function="prevLayout",
function_owner=self, position={-1,0.075,-0.6},
height=250, width=250, font_size=100,
font_color=fontColor, color=backgColor
})
self.createButton({ -- index 1, Selection Button
label="Selection Button", click_function="selectLayout",
function_owner=self, position={-0,0.075,-0.6},
height=250, width=720, font_size=100,
font_color=fontColor, color=backgColor
})
self.createButton({ -- index 2, Next Layout
label="-->", click_function="nextLayout",
function_owner=self, position={1,0.075,-0.6},
height=250, width=250, font_size=100,
font_color=fontColor, color=backgColor
})
self.createButton({ -- index 3, Number Display
label="0", click_function="none",
function_owner=self, position={-1.155,0.075,-1.108},
height=0, width=0, font_size=100,
font_color={1,1,1}, color={0,0,0}
})
self.createButton({ -- index 4, Instruction Display
label="Place a deck beside\n the tool and press the\n Find Deck button.", click_function="none",
function_owner=self, position={-0,0.075,0.8},
height=0, width=0, font_size=110,
font_color=fontColor, color={0,0,0}
})
self.createButton({ -- index 5, Find Deck
label="Find\nDeck", click_function="findDeck",
function_owner=self, position={1.06,0.075,-1.1},
height=250, width=320, font_size=80,
font_color={0.7,0.2,0.2}, color=backgColor
})
self.createButton({ -- index 6, Rotation On/Off
label="Rotation\nOn", click_function="rotationOnOff",
function_owner=self, position={-0.37,0.075,0},
height=250, width=445, font_size=100,
font_color=fontColor, color=backgColor
})
self.createButton({ -- index 7, Shuffle
label="Shuffle", click_function="shuffle",
function_owner=self, position={0.4,0.075,0},
height=250, width=330, font_size=100,
font_color=fontColor, color=backgColor
})
self.createButton({ -- index 8, Spawns and controls the Help Tablet
label="Help\nTablet", click_function="helpTablet",
function_owner=self, position={1.05,0.075,0},
height=250, width=320, font_size=100,
font_color=fontColor, color=backgColor
})
self.createButton({ -- index 9, Display used to
label="------------->", click_function="None",
function_owner=self, position={-0,0.075,-1.1},
height=0, width=0, font_size=130,
font_color={1,1,1}, color={0,0,0}
})
self.createButton({ -- index 10, Automatically select cards enable/disable
label="Manual\nDraw", click_function="autoSelectCards",
function_owner=self, position={-1.1,0.075,0},
height=250, width=300, font_size=80,
font_color={1,1,1}, color={0,0,0}
})
rotation = true
layout = nil
layoutNum = 0
cardPosX = nil
cardPosZ = nil
neededCards = nil
autoCards = false
activeButtonColor = {0.9,0.9,0.3}
selectNewCards = false
nextLayout()
end
selectedCards = {}
layoutFunctions = {
"none", --oneCardDraw
"none", --threeCardDraw
"none", --fiveCardDraw
"none", --celticCrossDraw
"none", --tetraktysDraw
"none", --crossAndTriangleDraw
"none", --astroDraw
"none", --planetaryDraw
"none", --treeOfLifeDraw
"none", --starGuideDraw
"none", --spiritualGuidanceDraw
"none", --doOrDontDraw
"none", --highPriestessDraw
"none", --careerPathDraw
"none", --pastLifeDraw
"none", --relationshipProblemsDraw
"none", --birthdayDraw
"none", --mandalaDraw
"none", --horseshoeDraw
"none", --opportunitiesAndObstaclesDraw
"none", --moneyProblemsDraw
"customCardsDraw",
}
layoutNames = {
"Single Card",
"Three Card",
"Five Card",
"Celtic Cross",
"Tetraktys",
"Cross & Triangle",
"Astrological",
"Planetary",
"Tree of Life",
"Star Guide",
"Spiritual\nGuidance",
"Should you? or\nShouldn't You?",
"Secret of the\nHigh Priestess",
"Career Path",
"Past Life",
"Relationship\nProblems",
"Birthday",
"Mandala",
"Horseshoe",
"Opportunities &\nObstacles",
"Money Problems",
"Custom Cards",
}
helpTabUrls = {
"https://dl.dropboxusercontent.com/s/ubokfwb2w0u6dnx/HomePage.png", -- Help Home Page
"https://dl.dropbox.com/s/ocqmv6jah0388pp/Single%20Card.png?dl=0", -- Single Card
"https://dl.dropbox.com/s/pd10yopytjp0oj8/Three%20Card.png?dl=0", -- Three Card
"https://dl.dropbox.com/s/6iva4pye4s8i92g/Five%20card.png?dl=0", -- Five Card
"https://dl.dropbox.com/s/mx8rjp9ybuy8jqu/celticCross.png?dl=0", -- Celtic Cross
"https://dl.dropbox.com/s/j4tdmbzojnfqb9d/Tetraktys.png?dl=0", -- Tetraktys
"https://dl.dropbox.com/s/ojjkkwobokwbguz/Cross%20and%20Triangle.png?dl=0", -- Cross & Triangle
"https://dl.dropbox.com/s/ppwqizeqjj5ohub/Astro%20Zodiac.png?dl=0", -- Astrological
"https://dl.dropbox.com/s/600ny3vhc2lvzrf/Planetary.png?dl=0", -- Planetary
"https://dl.dropbox.com/s/ynhwcc668lxoil3/Tree%20of%20Life.png?dl=0", -- Tree of Life
"https://dl.dropbox.com/s/r0b249ndjviac0v/Star%20Guide.png?dl=0", -- Star Guide
"https://dl.dropbox.com/s/a7n62u801aoqer6/Spiritual%20Guidance.png?dl=0", -- Spiritual Guidance
"https://dl.dropbox.com/s/w9kwlhlwu0tju74/Should%20you%2C%20shouldnt%20you.png?dl=0", -- Should you? or Shouldn't you?
"https://dl.dropbox.com/s/vhtnrze7tep0fl8/Secret%20of%20the%20High%20Priestess.png?dl=0", -- Secret of the High Priestess
"https://dl.dropbox.com/s/7i7p9emxyrev2mx/Career%20Path.png?dl=0", -- Career Path
"https://dl.dropbox.com/s/voxepwd9cjergdg/Past%20Life.png?dl=0", -- Past Life
"https://dl.dropbox.com/s/ravkl7f7cxl2dcm/Relationship%20Problems.png?dl=0", -- Relationship Problems
"https://dl.dropbox.com/s/zxuiufqnxfdkp8c/Birthday%20spread.png?dl=0", -- Birthday
"https://dl.dropbox.com/s/4rfsdxoymv76qdy/Mandala.png?dl=0", -- Mandala
"https://dl.dropbox.com/s/ersbnozvuxs5uds/Horseshoe.png?dl=0", -- Horseshoe
"https://dl.dropbox.com/s/ju4rylxx272l3zg/Opportunities%20and%20Obstacles.png?dl=0", -- Opportunities & Obstacles
"https://dl.dropbox.com/s/twfgho07d2od1sb/Money%20Problems.png?dl=0", -- Money Problems
"https://i.imgur.com/bVZuYKA.jpg", -- Custom Catds
}
function nextLayout()
if layout == nil then
if layoutNum <= 21 then
layoutNum = layoutNum + 1
self.editButton({index=3, label=layoutNum})
self.editButton({index=1, label=layoutNames[layoutNum], click_function=layoutFunctions[layoutNum]})
else
layoutNum = 1
self.editButton({index=3, label=layoutNum})
self.editButton({index=1, label=layoutNames[layoutNum], click_function=layoutFunctions[layoutNum]})
end
end
end
function prevLayout()
if layout == nil then
if layoutNum >= 2 then
layoutNum = layoutNum - 1
self.editButton({index=3, label=layoutNum})
self.editButton({index=1, label=layoutNames[layoutNum], click_function=layoutFunctions[layoutNum]})
else
layoutNum = 21
self.editButton({index=3, label=layoutNum})
self.editButton({index=1, label=layoutNames[layoutNum], click_function=layoutFunctions[layoutNum]})
end
end
end
function rotationOnOff() -- Enables or disables rotation; Rotation On/Off button.
if rotation == true then
rotation = false
local button_parameters = {}
self.editButton({index=6, label="Rotation\nOff"})
elseif rotation == false then
rotation = true
self.editButton({index=6, label="Rotation\nON"})
end
end
function autoSelectCards() -- designed to enable to disable user selecting cards.
if autoCards == false then
autoCards = true
self.editButton({index=10, label="Auto\nDraw"})
elseif autoCards == true then
autoCards = false
self.editButton({index=10, label="Manual\nDraw"})
end
end
function shuffle()
local cardsOnTable = getAllObjects()
for i,v in ipairs(cardsOnTable) do
if v.tag == "Card" then
cardsOnTable = true
end
end
if cardsOnTable == true then
startLuaCoroutine(self, "shuffleCoroutine")
elseif deckRef == nil then
print("To Shuffle, you must first find a deck with the Find Deck button.")
elseif deckRef ~= nil then
deckRef.shuffle()
end
end
function shuffleCoroutine() -- Resets all all cards back to the deck, and resets layout buttons.
self.editButton({index=4, font_size=110, label='Using the arrows, choose\na layout, and select it with\nthe center button labeled\n with the layout name.'})
setNotes("")
layout = nil
selectNewCards = false
local handCards = Player.Black.getHandObjects()
local deckPos = self.positionToWorld({3,0,0})
if #handCards > 0 then -- Resets cards from the hand back to the deck. This is used when the player wants to reset the deck mid draw.
for i,v in ipairs(handCards) do
deckPos.y = deckPos.y + 0.01
v.setPosition(deckPos)
for i=1,1,1 do coroutine.yield(0) end
end
end
findDeck()
if #selectedCards > 0 and deckRef ~= nil then
for _, object in ipairs(selectedCards) do -- uses the table and puts all selected cards back into the deck.
deckRef.putObject(object)
end
for i=1, 25,1 do coroutine.yield(0) end -- coroutine used to wait for cards to return before the table is wiped.
for k in pairs(selectedCards) do
selectedCards[k] = nil
end
end
local cardsOnTable = getAllObjects()
for _, objects in ipairs(cardsOnTable) do -- Moves any left over cards on the table to the deck.
if objects.tag == "Card" then
deckRef.putObject(objects)
end
end
self.editButton({index=1, font_color={1,1,1}})
for i=1,25,1 do coroutine.yield(0) end
deckRef.Shuffle()
return 1
end
function findDeck() -- "Find Deck" Button; finds deck within 5 units of tool.
local allObjects = getAllObjects()
foundDeck = false
for _, deckObjects in ipairs(allObjects) do
if deckObjects.tag == "Deck" then
local distance = findProximity(self.getPosition(), deckObjects)
if distance <= 5 then
deckGuid = deckObjects.getGUID()
deckRef = getObjectFromGUID(deckGuid)
--deckRef.setScale({0.89, 1.00, 0.89})
deckRef.setDescription(deckGuid)
self.editButton({index=9, font_size=100, position={-0,0.075,-1.1}, font_color={0,0.7,0.2}, label="GUID: "..deckGuid})
self.editButton({index=5, font_size=60, font_color={0,0.7,0.2}, label='Deck\nFound'})
foundDeck= true
end
end
end
if foundDeck == false and deckRef ~= nil then
self.editButton({index=9, font_size=55, font_color={0,0.7,0.2}, label='No Deck Found within 5 Units\nUsing last known deck\nGUID: '..deckGuid})
elseif deckRef == nil then
self.editButton({index=4, font_size=110, label='No deck found; place deck\n beside the tool and press\n the Find Deck Button.'})
elseif layout == nil then
self.editButton({index=4, font_size=110, label='Using the arrows, choose\na layout, and select it with\nthe center button labeled\n with the layout name.'})
end
end
function findProximity(targetPos, object) -- Used by "findDeck" to determine distance between tool and deck.
local objectPos = object.getPosition()
local xDistance = math.abs(targetPos.x - objectPos.x)
local zDistance = math.abs(targetPos.z - objectPos.z)
local distance = xDistance^2 + zDistance^2
return math.sqrt(distance)
end
function update() -- This update function watches for GUIDs that are input to the tools description box.
if self.getDescription() ~= nil then
local deckObj = getObjectFromGUID(self.getDescription())
if deckObj then
deckRef = deckObj
self.editButton({index=2, font_color={0,0.7,0.2}, label='Deck:\n'..deckObj.getGUID()})
--deckObj.setScale({0.89, 1.00, 0.89})
deckObj.setDescription(deckObj.getGUID())
foundDeck = true
end
self.setDescription("")
end
end
function drawCards()
startLuaCoroutine(self, "drawCardsCoroutine")
end
function drawCardsCoroutine()
local fontSize = 130
for i=1, 10,1 do coroutine.yield(0) end
Player.Black.setHandTransform({
position = {-0.39, 4.61, -8.14},
rotation = {0.00, 0.00, 0.00},
scale = {23.78, 1.65, 1.73},
})
local deckSize = deckRef.getObjects()
for i=1, #deckSize do
deckRef.dealToColorWithOffset({-14.5, 2, 0.19}, false, "Black")
selectNewCards = true
end
setNotes(layout..' - Choose '..neededCards..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..neededCards..' cards to\n continue.'})
broadcastToColor(layout..' layout selected', 'White')--, {0,1,0})
return 1
end
movingCards = false
function onObjectPickedUp(White, obj)
if obj.tag == "Card" and selectNewCards == true and movingCards == false then
cardRef = obj
startLuaCoroutine(self, "moveCard")
end
end
neededCards = nil
cardPosX = nil
cardPosZ = nil
function moveCard()
handCards = Player.Black.getHandObjects()
for i=1, 10 do
coroutine.yield(0)
end
local fontSize = 130
if #selectedCards <= neededCards and selectNewCards == true then
if #selectedCards == 0 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX, 1.6, cardPosZ})
table.insert( selectedCards, 1, cardRef)
card2 = neededCards - 1
setNotes(layout..' - Choose '..card2..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card2..' cards to\n continue.'})
elseif #selectedCards == 1 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+2.3, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card3 = neededCards - 2
setNotes(layout..' - Choose '..card3..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card3..' cards to\n continue.'})--this
elseif #selectedCards == 2 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+4.6, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card4 = neededCards - 3
setNotes(layout..' - Choose '..card4..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card4..' cards to\n continue.'})
elseif #selectedCards == 3 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+6.9, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card5 = neededCards - 4
setNotes(layout..' - Choose '..card5..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card5..' cards to\n continue.'})
elseif #selectedCards == 4 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+9.2, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card6 = neededCards - 5
setNotes(layout..' - Choose '..card6..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card6..' cards to\n continue.'})
elseif #selectedCards == 5 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+11.5, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card7 = neededCards - 6
setNotes(layout..' - Choose '..card7..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card7..' cards to\n continue.'})
elseif #selectedCards == 6 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+13.8, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card8 = neededCards - 7
setNotes(layout..' - Choose '..card8..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card8..' cards to\n continue.'})
elseif #selectedCards == 7 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+16.1, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card9 = neededCards - 8
setNotes(layout..' - Choose '..card9..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card9..' cards to\n continue.'})
elseif #selectedCards == 8 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+18.4, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card10 = neededCards - 9
setNotes(layout..' - Choose '..card10..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card10..' cards to\n continue.'})
elseif #selectedCards == 9 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+20.7, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card11 = neededCards - 10
setNotes(layout..' - Choose '..card11..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card11..' cards to\n continue.'})
elseif #selectedCards == 10 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+23, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card12 = neededCards - 11
setNotes(layout..' - Choose '..card12..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card12..' cards to\n continue.'})
elseif #selectedCards == 11 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+25.3, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card13 = neededCards - 12
setNotes(layout..' - Choose '..card13..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card13..' cards to\n continue.'})
elseif #selectedCards == 12 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+27.6, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card14 = neededCards - 13
setNotes(layout..' - Choose '..card14..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card14..' cards to\n continue.'})
elseif #selectedCards == 13 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+29.9, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card15 = neededCards - 14
setNotes(layout..' - Choose '..card15..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card15..' cards\n to continue.'})
end
end
for i=1,15,1 do coroutine.yield(0) end
if #selectedCards == neededCards then
selectNewCards = false
if selectNewCards == false then
setNotes('')
broadcastToColor("Done!", 'White')--, {0,2,0})
local unusedCards = Player.Black.getHandObjects()
local selfPos = self.positionToWorld({2.9,1,0})
for i,v in ipairs(unusedCards) do
v.setPosition(selfPos)
for i=1,1,1 do coroutine.yield(0) end
end
for i=1, 30,1 do coroutine.yield(0) end
pickedCardsFinished()
Player.Black.setHandTransform({
position = {-0.39, 160, -8.14},
rotation = {0.00, 0.00, 0.00},
scale = {23.78, 1.65, 1.73},
})
end
for i=1,30,1 do coroutine.yield(0) end
findDeck()
end
return 1
end
function altDraw()
startLuaCoroutine(self, "altDrawCoroutine")
end
function altDrawCoroutine()
if autoCards == true then
for i=1, neededCards do
if layout ~= nil then
local params = {}
params.callback = "autoDrawCallback"
params.callback_owner = self
params.position = {cardPosX, 2, cardPosZ}
deckRef.takeObject(params)
cardPosX = cardPosX + 2.3
for i=1,15,1 do coroutine.yield(0) end
end
end
end
return 1
end
function autoDrawCallback(card)
local cardLoc = card.getPosition()
if rotation == true and math.random(2) == 1 then -- rotation was used here instead of within takeObject so the movement would not be seen.
card.setRotation({cardLoc.x, cardLoc.y, 180})
else
cardLoc.y = cardLoc.y + 180
card.setRotation({cardLoc.x, cardLoc.y, 180})
end
table.insert( selectedCards, card)
if #selectedCards == neededCards then
pickedCardsFinished()
end
end
function helpTablet()
local targetPos = self.positionToWorld({0,1,-3.6})
if tabletRef == nil then
spawnObject({
type = "Tablet",
rotation = {0.00, 179.99, 0.00},
position = targetPos,
scale = {0.40, 0.40, 0.40},
callback_owner = self,
callback = "helpTabletCallback",
params = {"tab"}
})
else
if tabletRef ~= nil then
local currentUrl = tabletRef.getValue()
if currentUrl == helpTabUrls[1] then
tabletRef.setValue("http://psychiclibrary.com/beyondBooks/tarot-deck/")
elseif currentUrl == "http://psychiclibrary.com/beyondBooks/tarot-deck/" then
tabletRef.setValue(helpTabUrls[1])
elseif currentUrl ~= helpTabUrls[1] or currentUrl ~= "http://psychiclibrary.com/beyondBooks/tarot-deck/" then
tabletRef.setValue(helpTabUrls[1])
end
end
end
end
function helpTabletCallback(tab)
local tabletGuid = tab.getGUID()
tabletRef = getObjectFromGUID(tabletGuid)
tab.setName("Tarot Help Tablet")
tab.setValue(helpTabUrls[1])
end
function selectLayout()
return 1
end
function customCardsDraw()
neededCards = 5
cardPosX = 0.00
cardPosZ = -13.78
layout = "Custom Cards"
autoCards = true
customDraw()
end
function customDraw()
startLuaCoroutine(self, "customDrawCoroutine")
end
function customDrawCoroutine()
if autoCards == true then
local cardPositions = {
{68.00, 5.00, -13.60}, -- Sai
{68.00, 5.00, 13.60}, --Zerrik
{68.00, 5.00, -6.80}, --Varan
{68.00, 5.00, 6.80}, --Bobby
{68.00, 5.00, 0.00}, --Erik
}
if debug then
cardPositions = {
{0, 2.00, -8}, -- Sai
{0, 2.00, -4}, --Zerrik
{0, 2.00, 4}, --Varan
{0, 2.00, 8}, --Bobby
{0, 2.00, 0}, --Erik
}
end
for i=1, neededCards do -- drawing cards and initial position
if layout ~= nil then
local params = {}
params.callback = "customDrawCallback"
params.callback_owner = self
params.position = cardPositions[i]
params.rotation = {0.00, 90.00, 180.00}
deckRef.takeObject(params)
for i=1,45,1 do coroutine.yield(0) end
end
end
end
return 1
end
function customDrawCallback(card)
card.setLock(true)
--card.setScale({1.83, 1, 1.83})
table.insert( selectedCards, card)
if #selectedCards == neededCards then
customFinished()
end
end
function customFinished()
startLuaCoroutine(self, "customFinishedCoroutine")
end
function customFinishedCoroutine()
local cardFinalPos = { -- cards in "hand"
{-74.82, 2.00, -49.30}, --Sai
{40.80, 2.00, 49.30}, --Zerrik
{-37.40, 2.00, 49.30}, --Varan
{-17.00, 2.00, 49.30}, --Bobby
{-16.15, 2.00, -48.45}, --Erik
}
local cardMidPos = { -- cards in formation
{-5.10, 4.45, -5.10}, --Sai
{5.10, 4.45, -5.10}, --Zerrik
{-5.10, 4.45, 5.10}, --Varan
{5.10, 4.45, 5.10}, --Bobby
{0.00, 4.45, 0.00}, --Erik
}
local cardRot = {
{0.00, 180.00, 0.00}, --Sai
{0.00, 0.00, 0.00}, --Zerrik
{0.00, 0.00, 0.00}, --Varan
{0.00, 0.00, 0.00}, --Bobby
{0.00, 180.00, 0.00}, --Erik
}
for i,v in ipairs(selectedCards) do -- setting to 0
local targetPos = v.positionToWorld({0,0,0})
v.setPositionSmooth(targetPos)
end
-- "shuffling"
local locZ = selectedCards[#selectedCards].getPosition()
for i,v in ipairs(selectedCards) do
local targetPos = v.getPosition()
targetPos.y = targetPos.y+i*0.05
targetPos.z = locZ.z
targetPos.x = locZ.z
v.setPositionSmooth(targetPos,false,false)
end
for i=1,60,1 do coroutine.yield(0) end
deckRef.shuffle()
local curRot = selectedCards[1].getRotation()
local steps = 20
for i=1,steps do
local rot = (curRot.y*i)/steps
selectedCards[1].setRotation({curRot.x,rot,curRot.z})
coroutine.yield(0)
end
deckRef.shuffle()
local curRot = selectedCards[3].getRotation()
local steps = 20
for i=1,steps do
local rot = (curRot.y*i)/steps
selectedCards[1].setRotation({curRot.x,rot,curRot.z})
coroutine.yield(0)
end
for i=1,45,1 do coroutine.yield(0) end -- setting to formation
for i,v in ipairs(selectedCards) do
local targetPos = cardMidPos[i]
v.setPositionSmooth(targetPos)
end
for i=1,60,1 do coroutine.yield(0) end -- going to hand
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardFinalPos[i])
v.setRotationSmooth(cardRot[i])
v.setLock(false)
--v.flip()
for i=1, 15,1 do coroutine.yield(0) end
end
selectedCards = {}
return 1
end
function allResting(arr)
for i=1, #arr do
if not arr[i].resting then
return false
end
end
return true
end
function oneCardDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 1
cardPosX = 0.00
cardPosZ = -13.78
layout = "Single Card"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[2])
end
end
function threeCardDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 3
cardPosX = -2.30
cardPosZ = -13.78
layout = "Three Card"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[3])
end
end
function fiveCardDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 5
cardPosX = -4.60
cardPosZ = -13.78
layout = "Five Card"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[4])
end
end
function celticCrossDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 10
cardPosX = -10.37
cardPosZ = -13.78
layout = "Celtic Cross"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[5])
end
end
function tetraktysDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 10
cardPosX = -10.37
cardPosZ = -13.78
layout = "Tetraktys"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[6])
end
end
function astroDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 13
cardPosX = -13.87
cardPosZ = -13.78
layout = "Astrological"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[8])
end
end
function planetaryDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 8
cardPosX = -8.13
cardPosZ = -13.78
layout = "Planetary"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[9])
end
end
function treeOfLifeDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 10
cardPosX = -10.37
cardPosZ = -13.78
layout = "Tree Of Life"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[10])
end
end
function crossAndTriangleDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 9
cardPosX = -9.23
cardPosZ = -13.78
layout = "Cross & Triangle"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[7])
end
end
function relationshipProblemsDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 9
cardPosX = -9.23
cardPosZ = -13.78
layout = "Relationship Problems"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[17])
end
end
function moneyProblemsDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 5
cardPosX = -4.60
cardPosZ = -13.78
layout = "Money Problems"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[22])
end
end
function pastLifeDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 14
cardPosX = -14.93
cardPosZ = -13.78