-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage-changer.lua
47 lines (40 loc) · 1.29 KB
/
image-changer.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
--Runs when the scripted button inside the button is clicked
function buttonPress()
if lockout == false then
local gm = self.getGMNotes()
local obj = getObjectFromGUID(gm)
local img = self.getDescription()
obj.setCustomObject({image = img})
obj.reload()
obj.highlightOn(Color.White, 2)
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
--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