-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGreen-Red Playmat.ttslua
114 lines (98 loc) · 3.72 KB
/
Green-Red Playmat.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
-- ~~~~~~
-- Script by dzikakulka
-- Issues, history at: https://github.com/tjakubo2/TTS_xwing
--
-- Script applicable to playmats on both sides of the table
-- ~~~~~~
-- TO ADD NEW IMAGES TO THE SET
-- Just add their links to the table below in the same fashion
-- (comma after the currrent last one and your link enclosed in apostrophes following)
-- Table of all images to be cycled through with NextImage()
imageSet = {'http://i.imgur.com/dczrasC.jpg',
'http://i.imgur.com/6IkNucB.jpg',
'http://i.imgur.com/dKYBJMX.png',
'http://i.imgur.com/8tDK0x8.png',
'http://i.imgur.com/sb2AJOz.png',
'http://i.imgur.com/V7pWVak.png',
'http://i.imgur.com/spWTWy7.png',
'http://i.imgur.com/YdIAcvP.png',
'http://i.imgur.com/5CcjDzM.jpg',
'http://i.imgur.com/4WMSCSV.jpg',
'http://i.imgur.com/0FWrq21.jpg',
'http://i.imgur.com/x4LEk1A.jpg',
'http://i.imgur.com/fy6kooO.png'}
-- {Postions, Scale} data for mat object of each type
matData = {}
matData['Custom_Board'] = {{20.5142, -0.17, 0}, {1.225, 1.2, 1.225}}
matData['Custom_Tile'] = {{20.5142, 0.85, 0}, {16.28, 0, 16.28}}
-- Changes data to "left version" and switches 1st image if on left side
function onLoad()
local function leftVersion(data)
return { {-1*data[1][1], data[1][2], data[1][3]}, {data[2][1], data[2][2], data[2][3]} }
end
if self.getPosition()[1] < 0 then
for k,v in pairs(matData) do matData[k] = leftVersion(matData[k]) end
local temp = imageSet[1]
imageSet[1] = imageSet[2]
imageSet[2] = temp
end
self.lock()
self.setPosition(matData[SelfType()][1])
self.setScale(matData[SelfType()][2])
self.setRotation({0, 180, 0})
self.interactable = false
end
-- Differentiates self type between Custom_Tile and Custom_Board
function SelfType()
if self.getCustomObject().thickness ~= nil then
return 'Custom_Tile'
else
return 'Custom_Board'
end
end
-- Respawn self (with same image)
-- if typeChange is TRUE, change type Tile <-> Board
function Respawn(typeChange)
local newType = SelfType()
if typeChange == true and SelfType() == 'Custom_Tile' then
newType = 'Custom_Board'
elseif typeChange == true then
newType = 'Custom_Tile'
end
local newMatProperties = {}
newMatProperties.type = newType
newMatProperties.position = matData[newType][1]
newMatProperties.rotation = self.getRotation()
newMatProperties.scale = matData[newType][2]
newMat = spawnObject(newMatProperties)
newMat.setLuaScript(self.getLuaScript())
local currentImageNum = 1
if self.getVar('ImageNum') ~= nil then currentImageNum = self.getVar('ImageNum') end
local customMatParams = {}
customMatParams.image = imageSet[currentImageNum]
if newType == 'Custom_Tile' then
customMatParams.type = 0
customMatParams.thickness = 0.1
end
newMat.setCustomObject(customMatParams)
newMat.setVar('ImageNum', currentImageNum)
newMat.setName(self.getName())
self.destruct()
end
function ChangeType()
Respawn(true)
end
-- Change image to the next from the list
-- Image numbers wrap around
-- RESPAWNS MAT OBJECT (neccesary to actually render with new image)
function NextImage()
local currentImageNum = 1
if self.getVar('ImageNum') ~= nil then currentImageNum = self.getVar('ImageNum') end
if imageSet[currentImageNum + 1] ~= nil then
currentImageNum = currentImageNum + 1
else
currentImageNum = 1
end
self.setVar('ImageNum', currentImageNum)
Respawn(false)
end