-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpin-positioner.lua
69 lines (61 loc) · 1.97 KB
/
pin-positioner.lua
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
--Runs when the scripted button inside the button is clicked
function buttonPress()
if lockout == false then
local desc = self.getDescription()
if desc ~= "" then
local obj = getObjectFromGUID(desc)
local notes = obj.getGMNotes()
local pos = {}
local rot = {}
if notes == "" then
pos = {115.27, 11.88, -79.46}
rot = {347.94, 314.99, 0.35}
else
local vars = JSON.decode(notes)
pos = {vars.pos[1], vars.pos[2], vars.pos[3]}
rot = {vars.rot[1], vars.rot[2], vars.rot[3]}
end
obj.setPositionSmooth(pos, false, true)
obj.setRotationSmooth(rot, false, true)
obj.setLock(true)
self.setDescription("")
end
self.AssetBundle.playTriggerEffect(0) --triggers animation/sound
lockout = true --locks out the button
startLockoutTimer() --Starts up a timer to remove lockout
end
end
--Runs on load, creates button and makes sure the lockout is off
function onload()
self.createButton(
{
label = "Big Red Button\n\nBy: MrStump",
click_function = "buttonPress",
function_owner = self,
position = {0, 0.25, 0},
height = 1400,
width = 1400
}
)
lockout = false
end
function onCollisionEnter(info)
local obj = info.collision_object
if obj.interactable then
if obj.getGUID() then
self.setDescription(obj.getGUID())
end
end
end
--Starts a timer that, when it ends, will unlock the button
function startLockoutTimer()
Timer.create({identifier = self.getGUID(), function_name = "unlockLockout", delay = 0.5})
end
--Unlocks button
function unlockLockout()
lockout = false
end
--Ends the timer if the object is destroyed before the timer ends, to prevent an error
function onDestroy()
Timer.destroy(self.getGUID())
end