-
Notifications
You must be signed in to change notification settings - Fork 4
/
TravelerToken.ttslua
41 lines (36 loc) · 1.62 KB
/
TravelerToken.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
VOTE_TOKEN_BAG_GUID = 'aa3ceb'
function onLoad()
createFlipButtons()
voteTokenBag = getObjectFromGUID(VOTE_TOKEN_BAG_GUID)
end
function createFlipButtons()
self.clearButtons()
self.createButton({click_function = 'flipAliveToDead', function_owner = self, position = {0,0.3,0}, rotation = {0,0,0}, width = 400, height = 400, color = {0,0,0,0}, tooltip = 'Flip Life Token'})
self.createButton({click_function = 'flipDeadToAlive', function_owner = self, position = {0,-0.1,0}, rotation = {180,0,0}, width = 700, height = 700, color = {0,0,0,0}, tooltip = 'Flip Life Token'})
end
function flipAliveToDead(clickedObject, playerColor)
if playerColor == 'Black' then
self.setLock(true)
local pos = clickedObject.getPosition()
pos['y'] = 1.36
clickedObject.setPositionSmooth(pos)
clickedObject.setRotationSmooth({180,0,0})
voteTokenBag.takeObject({position = pos})
Wait.time(function () Global.call('checkLiving') end, 1)
end
end
function flipDeadToAlive(clickedObject, playerColor)
if playerColor == 'Black' then
local pos = clickedObject.getPosition()
local objectsFound = Physics.cast({origin = pos, direction = {0, 1, 0}, type = 2, max_distance = 3, debug = false})
pos['y'] = 1.15
clickedObject.setPositionSmooth(pos)
clickedObject.setRotationSmooth({0,0,0})
for i, hit in ipairs(objectsFound) do
if hit.hit_object.getName() == 'Vote Token' then
voteTokenBag.putObject(hit.hit_object)
end
end
Wait.time(function () Global.call('checkLiving') end, 1)
end
end