-
Notifications
You must be signed in to change notification settings - Fork 0
/
interactable.lua
73 lines (65 loc) · 2.05 KB
/
interactable.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
function onLoad(save_state)
self.createButton(
{
click_function = "make_interact",
function_owner = self,
label = "Make Interactable",
position = {0, 0.5, 0.8},
scale = {0.5, 0.5, 0.5},
width = 3300,
height = 600,
font_size = 400,
color = {0.192, 0.701, 0.168, 1}
}
)
self.createButton(
{
click_function = "make_not_interact",
function_owner = self,
label = "Make Non-Interactable",
position = {0, 0.5, 1.6},
scale = {0.5, 0.5, 0.5},
width = 4200,
height = 600,
font_size = 400,
color = {0.856, 0.1, 0.094, 1}
}
)
end
function isMe(id)
return id == self.getGUID()
end
function onCollisionEnter(info)
local id = info.collision_object.getGUID()
self.setDescription("Found: " .. id .. "\nMyself: " .. self.guid)
end
function make_interact(obj, player_clicker_color, alt_click)
local id = self.getDescription()
if Player[player_clicker_color].admin and not isMe(id) then
local id = self.getDescription()
if id == "" then
return
end
local o = getObjectFromGUID(id)
o.interactable = true
self.setDescription("")
Player[player_clicker_color].pingTable(getObjectFromGUID(id).getPosition())
local code = "function onload() self.interactable = true end"
o.setLuaScript(code)
end
end
function make_not_interact(obj, player_clicker_color, alt_click)
if Player[player_clicker_color].admin and not isMe(id) then
local id = self.getDescription()
if id == "" then
return
end
local o = getObjectFromGUID(id)
o.interactable = false
o.setLock(true)
self.setDescription("")
Player[player_clicker_color].pingTable(getObjectFromGUID(id).getPosition())
local code = "function onload() self.interactable = false end"
o.setLuaScript(code)
end
end