-
Notifications
You must be signed in to change notification settings - Fork 0
/
players.ttslua
68 lines (66 loc) · 1.6 KB
/
players.ttslua
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
playerObjectGUIDs = {
White = {
tray = 'ede27e',
trayLiner = '05eab9',
zone = '2a420b'
},
Red = {
tray = 'c5ccf0',
trayLiner = 'd4880b',
zone = '968c8d'
},
Green = {
tray = '8313d4',
trayLiner = '382bd8',
zone = '64c12e'
},
Blue = {
tray = '34cb12',
trayLiner = '435c47',
zone = 'f2e70a'
},
Purple = {
tray = '45461a',
trayLiner = '933cba',
zone = '7dc2c1'
}
}
playerCharacters = {}
function assignCharacters()
availableCharacters = {}
availableCharacterCount = 0
for id, _ in pairs(characterData) do
availableCharacters[id] = true
availableCharacterCount = availableCharacterCount + 1
end
players = Player.getPlayers()
for _, player in pairs(players) do
zone = getObjectFromGUID(playerObjectGUIDs[player.color]['zone'])
for _, object in pairs(zone.getObjects()) do
id = characterIDFromBag(object)
if id != nil then
playerCharacters[player.color] = id
availableCharacters[id] = nil
availableCharacterCount = availableCharacterCount - 1
break
end
end
end
if #playerCharacters < #players then
for _, player in pairs(players) do
if playerCharacters[player.color] == nil then
n = math.random(availableCharacterCount)
i = 1
for id, _ in pairs(availableCharacters) do
if i == n then
playerCharacters[player.color] = id
availableCharacters[id] = nil
availableCharacterCount = availableCharacterCount - 1
break
end
i = i + 1
end
end
end
end
end