-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug-button.lua
101 lines (87 loc) · 2.32 KB
/
debug-button.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
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
local _stuffs = {
{obj = "28f96e", bag = "e1e28a"},
{obj = "1d7e9d", bag = "627199"},
{obj = "b81df8", bag = "de97c2"}
}
local _snap = nil
local _color = nil
function onLoad()
self.setRotation({0.00, 0.00, 0.00})
self.createButton(
{
click_function = "store_stuff",
function_owner = self,
label = "Store Stuff",
position = {0, 0.5, 0},
rotation = {0, 180, 0},
scale = {0.4, 0.7, 0.4},
width = 1600,
height = 450,
font_size = 320
}
)
local notes = self.getGMNotes()
local vars = JSON.decode(notes)
if vars.stuff then
_stuffs = vars.stuff
end
if vars.snap ~= nil then
_snap = vars.snap
end
if vars.color ~= nil then
_color = hexToRgb(vars.color)
end
store_stuff()
end
function store_stuff()
for i = 1, #_stuffs do
local o = getObjectFromGUID(_stuffs[i].obj)
local put =
o.clone(
{
position = {
x = o.getPosition().x,
y = o.getPosition().y + 3,
z = o.getPosition().z
}
}
)
put.setLock(true)
local b = getObjectFromGUID(_stuffs[i].bag)
if _color ~= nil then
b.setColorTint(_color)
end
if _snap ~= nil then
put.use_grid = _snap
put.use_snap_points = _snap
end
Wait.time(
function()
b.reset()
local waiter = function()
return put.resting
end
local waited = function()
local pos = b.getPosition()
pos.y = pos.y + 2
put.setLock(false)
put.setPositionSmooth(pos, false, true)
end
Wait.condition(waited, waiter)
end,
1.2
)
end
end
function hexToRgb(hex)
hex = hex:gsub("#", "")
if #hex < 8 then
hex = hex .. "ff"
end
return color(
tonumber("0x" .. hex:sub(1, 2), 16) / 255,
tonumber("0x" .. hex:sub(3, 4), 16) / 255,
tonumber("0x" .. hex:sub(5, 6), 16) / 255,
tonumber("0x" .. hex:sub(7, 8), 16) / 255
)
end