-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem-stack.lua
84 lines (74 loc) · 2.09 KB
/
item-stack.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
function onLoad()
self.createButton(
{
click_function = "stack",
function_owner = self,
label = " ",
position = {0, 0.1, 0},
scale = {0.5, 0.5, 0.5},
width = 750,
height = 750,
font_size = 400,
color = {0.5, 0.5, 0.5, 1},
tooltip = "Stack buttons"
}
)
self.setGMNotes("")
end
function onCollisionEnter(info)
if info then
local obj = info.collision_object
if obj then
if obj.interactable then
if obj.getGUID() then
local returner = {}
local gm = self.getGMNotes()
local json = JSON.decode(gm)
if json then
returner = json
end
table.insert(returner, obj.getGUID())
self.setGMNotes(JSON.encode(returner))
end
end
end
end
end
-- function onObjectCollisionEnter(hit_object, collision_info)
-- -- collision_info table:
-- -- collision_object Object
-- -- contact_points Table {Vector, ...}
-- -- relative_velocity Vector
-- local returner = {}
-- local gm = self.getGMNotes()
-- local json = JSON.decode(gm)
-- if #json > 0 then
-- returner = json
-- end
-- if hit_object.interactable then
-- local id = hit_object.getGUID()
-- table.insert(returner, id)
-- self.setGMNotes(JSON.encode(returner))
-- end
-- end
function stack()
local gm = self.getGMNotes()
local objs = JSON.decode(gm)
local pos = self.getPosition()
local rot = self.getRotation()
pos.x = pos.x - 7
pos.y = pos.y + 10
for i, obj in ipairs(objs) do
local o = getObjectFromGUID(obj)
if o then
Wait.time(
function()
o.setPosition(pos)
o.setRotation({0, 0, 0})
end,
0.2 * i
)
end
end
self.setGMNotes("")
end