-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectorv6.ttslua
91 lines (82 loc) · 5 KB
/
selectorv6.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
buttons = {}
buttons["Hook"] = {click_function = "switchHook", function_owner = self, label = " ", position = {-0.82, 0, -0.58}, scale = {0.7, 1, 0.7}, width = 310, height = 400, font_size = 200, tooltip = "Captain Hook"}
buttons["Queen"] = {click_function = "switchQueen", function_owner = self, label = " ", position = {-0.4, 0, -0.58}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Queen of Hearts"}
buttons["Facilier"] = {click_function = "switchFacilier", function_owner = self, label = " ", position = {0, 0, -0.58}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Dr. Facilier"}
buttons["Ratigan"] = {click_function = "switchRatigan", function_owner = self, label = " ", position = {0.4, 0, -0.58}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Ratigan"}
buttons["Cruella"] = {click_function = "switchCruella", function_owner = self, label = " ", position = {0.82, 0, -0.58}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Cruella de Vil"}
buttons["Malifecent"] = {click_function = "switchMalifecent", function_owner = self, label = " ", position = {-0.82, 0, 0}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Maleficent"}
buttons["John"] = {click_function = "switchJohn", function_owner = self, label = " ", position = {-0.4, 0, 0}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Prince John"}
buttons["EvilQ"] = {click_function = "switchEvilQ", function_owner = self, label = " ", position = {0, 0, 0}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Evil Queen"}
buttons["Yzma"] = {click_function = "switchYzma", function_owner = self, label = " ", position = {0.4, 0, 0}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Yzma"}
buttons["Pete"] = {click_function = "switchPete", function_owner = self, label = " ", position = {0.82, 0, 0}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Pete"}
buttons["Jafar"] = {click_function = "switchJafar", function_owner = self, label = " ", position = {-0.82, 0, 0.58}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Jafar"}
buttons["Ursula"] = {click_function = "switchUrsula", function_owner = self, label = " ", position = {-0.4, 0, 0.58}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Ursula"}
buttons["Hades"] = {click_function = "switchHades", function_owner = self, label = " ", position = {0, 0, 0.58}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Hades"}
buttons["Scar"] = {click_function = "switchScar", function_owner = self, label = " ", position = {0.4, 0, 0.58}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Scar"}
buttons["Gothel"] = {click_function = "switchGothel", function_owner = self, label = " ", position = {0.82, 0, 0.58}, scale = {0.7, 1, 0.7}, width = 310, height = 400, tooltip = "Mother Gothel"}
function createButtons()
for k, b in pairs(buttons) do
self.createButton(b)
_G['switch'..k] = function(o, color) switchCharacter(k, color) end
end
self.createButton({click_function = "SwitchRandom", function_owner = self, label = "Select a\nRandom Villain", position = {0, -0.1, 0}, rotation = {0, 0, 180}, scale = {0.7, 1, 0.7}, width = 1310, height = 1100, font_size = 180, tooltip="Select a random Villain"})
end
function onLoad(save_state)
log("Setting everything on "..self.guid)
EVERYTHING = find_object_by_name("The keeper of information").getTable('EVERYTHING')
createButtons()
end
function getChar(char)
local objects = {}
if EVERYTHING.Official[char] ~= nil then
objects=EVERYTHING.Official[char].data
end
if #objects==0 then
print("Character not found")
end
return objects
end
function SwitchRandom(_, player)
local choices = {}
for k, _ in pairs(EVERYTHING.Official) do
table.insert(choices, k)
end
switchCharacter(choices[math.random(1,#choices)], player, true)
end
function switchCharacter(character, color, random)
local my_rot = self.getRotation()
local objects = getChar(character)
local scale = self.getScale()
scale.x = 1/scale.x
scale.z = 1/scale.z
self.destruct()
function callback(o)
o.setRotation({o.getRotation().x, o.getRotation().y+my_rot.y, o.getRotation().z})
end
for _,v in ipairs(objects) do
local vec = Vector(v.move_to) * scale
if random then
vec = vec * Vector({-1, -0.9, 1})
end
local new_pos = self.positionToWorld(vec)
spawnObjectJSON({
json = v.json,
position = new_pos,
callback_function = callback
})
end
local direction = Vector(0, 4, 12)
direction:rotateOver("y", my_rot.y)
-- forward = forward*2
Player[color].setHandTransform({
position = self.getPosition()+direction,
rotation = {0, my_rot.y+180, 0},
scale = {8, 6, 4}
})
end
function find_object_by_name(name)
for _, obj in ipairs(getAllObjects()) do
if obj.getName() == name then return obj end
end
return nil
end