-
Notifications
You must be signed in to change notification settings - Fork 2
/
TFA Set Asteroids.ttslua
181 lines (159 loc) · 4.8 KB
/
TFA Set Asteroids.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
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
-- ~~~~~~
-- Script by dzikakulka
-- Issues, history at: https://github.com/tjakubo2/TTS_xwing
--
-- Script applicable to any object that allows control
-- over playmat and setup rulers on side it is loaded on
-- ~~~~~~
function onLoad()
selfSide = 1
controlledMatName = 'Teal-Blue Playmat'
if self.getPosition()[1] < 0 then
selfSide = -1
controlledMatName = 'Green-Red Playmat'
end
rulersOnLoad()
playmatOnLoad()
end
-- Transform a position to the side this object is on
function sPos(pos)
return {selfSide*pos[1], pos[2], pos[3]}
end
-- AUTO RULERS SCRIPT
local rulers = {}
local rulersState = 0 -- 0: none, 1: roid setup, 2: ship setup
local rulerData = {}
rulerData.mesh = 'http://pastebin.com/raw.php?i=MLLajD97'
rulerData.collider = 'http://pastebin.com/raw.php?i=MLLajD97'
rulerData.diffuse = 'http://i.imgur.com/46CSDvj.jpg'
rulerData.material = 1
local roidRot = {
{ 0, 270, 180},
{ 0, 180, 180},
{ 0, 270, 180},
{ 0, 0, 180},
{ 0, 0, 180},
{ 0, 90, 180},
{ 0, 90, 180},
{ 0, 180, 180}
}
local setupRot = {
{0, 270, 0},
{0, 0, 0},
{0, 270, 0},
{0, 0, 0},
{0, 0, 0},
{0, 90, 0},
{0, 180, 0},
{0, 90, 0},
{0, 180, 0},
{0, 180, 0}
}
local roidPos = {
{ 29.872200088501, 0.99871951341629, -10.8846182632446}, -- pio
{ 31.382360534668, 0.998719453811646, -9.37833354949951}, -- poz
{ 11.1684393310547, 0.998719573020935, -10.8876889038086},
{ 9.64546291351318, 0.998719453811646, -9.37820747375488},
{ 9.64722316741943, 0.99871951341629, 9.37365325927734},
{ 11.1658749008179, 0.998719453811646, 10.8807905578613},
{ 29.8585949707031, 0.998719394207001, 10.8395362091064}, -- pio
{ 31.3808876037598, 0.998719453811646, 9.32834770202637} -- poz
}
local setupPos = {
{ 3.97240991592407, 1.00172388553619, -10.8451750564575}, --pio
{ 9.67806907653809, 1.00172448158264, -12.4075313186646},
{ 37.0594985961914, 1.00172400474548, -10.8700817108154}, --pio
{ 20.5256023406982, 1.0017237663269, -12.4035499572754},
{ 31.3721223449707, 1.00172340869904, -12.4002779006958},
{ 3.97240991592407, 1.00172388553619, 10.8451750564575}, --pio
{ 9.67806907653809, 1.00172448158264, 12.4075313186646},
{ 37.0594985961914, 1.00172400474548, 10.8700817108154}, --pio
{ 20.5256023406982, 1.0017237663269, 12.4035499572754},
{ 31.3721223449707, 1.00172340869904, 12.4002779006958},
}
local corrScale = {0.625, 0.625, 0.625}
function rulersOnLoad()
local button = {}
button.click_function = 'toggleRulers'
button.function_owner = self
button.label = 'TOGGLE RULERS'
button.position = {8, 0.1, 0}
button.rotation = {0, 90, 0}
button.width = 4000
button.height = 1200 -- 40
button.font_size = 500
self.createButton(button)
end
function toggleRulers()
deleteAll()
rulersState = rulersState + 1
if rulersState == 1 then
spawnSet(roidPos, roidRot)
elseif rulersState == 2 then
spawnSet(setupPos, setupRot)
elseif rulersState == 3 then
rulersState = 0
end
end
function spawnSet(posTable, rotTable)
for k,pos in pairs(posTable) do
local params = {} -- 50
params.type = 'Custom_Model'
params.position = sPos(posTable[k])
params.rotation = rotTable[k]
obj = spawnObject(params)
obj.setCustomObject(rulerData)
obj.setScale(corrScale)
obj.lock()
obj.setDescription('autoruler')
table.insert(rulers, obj)
end
end
function deleteAll()
for k,ruler in pairs(rulers) do ruler.destruct() ruler = nil end
end
function onObjectDestroyed(obj)
if obj.getDescription() == 'autoruler' then
for k, v in pairs(rulers) do
if v == obj then table.remove(rulers, k) end
end
end
end
-- END AUTO RULERS SCRIPT
-- PLAYMAT IMAGE CHANGE SCRIPT
matObject = nil
function playmatOnLoad()
local button = {}
button.click_function = 'callImageChange'
button.function_owner = self
button.label = 'NEXT PLAYMAT'
button.position = {12, 0.1, 0}
button.rotation = {0, 90, 0}
button.width = 4000
button.height = 1200 -- 40
button.font_size = 500
self.createButton(button)
button.click_function = 'callTypeChange'
button.function_owner = self
button.label = 'CHANGE MAT TYPE'
button.position = {15, 0.1, 0}
button.rotation = {0, 90, 0}
button.width = 4000
button.height = 1200 -- 40
button.font_size = 450
self.createButton(button)
end
function callImageChange()
updatePlaymatRef()
matObject.call('NextImage')
end
function callTypeChange()
updatePlaymatRef()
matObject.call('ChangeType')
end
function updatePlaymatRef()
for k,obj in pairs(getAllObjects()) do
if obj.getName() == controlledMatName then matObject = obj end
end
end
-- PLAYMAT IMAGE CHANGE SCRIPT