-
Notifications
You must be signed in to change notification settings - Fork 0
/
pin.lua
126 lines (112 loc) · 3.51 KB
/
pin.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
function onLoad(save_state)
local desc = self.getDescription()
local label = ""
if desc ~= "" then
label = desc
end
--self.createButton(
-- {
-- click_function = "none",
-- function_owner = self,
-- label = label,
-- position = {0, 0, 1},
-- rotation = {-90, 0, 0},
-- scale = {0.5, 0.5, 0.5},
-- width = 2000,
-- height = 900,
-- font_size = 250,
-- alignment = 3
-- }
--)
self.UI.setAttribute("txt", "text", label)
if label == "" then
self.UI.setAttribute("bg", "color", "#ffffff00")
else
self.UI.setAttribute("bg", "color", "#ffffffaa")
if hasSecondLine(label) then
self.UI.setAttribute("bg", "height", "60")
else
self.UI.setAttribute("bg", "height", "30")
end
end
self.addContextMenuItem("[1A4F8B]Aquila[-]", aquila)
self.addContextMenuItem("[76922B]Ekehm[-]", ekehm)
self.addContextMenuItem("[813CA3]Mourning Lands[-]", ml)
self.addContextMenuItem("[9B1412]Oshil[-]", oshil)
self.addContextMenuItem("[B03900]Trisen[-]", trisen)
self.addContextMenuItem("[8AB90D]Zunirth[-]", zunirth)
self.addContextMenuItem("[39CCCC]Save[-]", save)
self.addContextMenuItem("[1E6D6D]Reposition[-]", repos)
end
local _reposPos = {129.35, 4, -29.81}
function repos(player_color)
if (player_color == "Black") then
self.setPositionSmooth(_reposPos, false, false)
self.setRotation({0, 270, 0})
self.setLock(false)
end
end
function save()
local curPos = self.getPosition()
local curRot = self.getRotation()
local vals = {
pos = {
tonumber(string.format("%.2f", curPos.x)),
tonumber(string.format("%.2f", curPos.y)),
tonumber(string.format("%.2f", curPos.z))
},
rot = {
tonumber(string.format("%.2f", curRot.x)),
tonumber(string.format("%.2f", curRot.y)),
tonumber(string.format("%.2f", curRot.z))
}
}
self.setGMNotes(JSON.encode(vals))
end
function none()
end
function aquila()
self.setColorTint({r = 27 / 255, g = 80 / 255, b = 140 / 255})
end
function trisen()
self.setColorTint({r = 176 / 255, g = 58 / 255, b = 0 / 255})
end
function oshil()
self.setColorTint({r = 155 / 255, g = 21 / 255, b = 19 / 255})
end
function zunirth()
self.setColorTint({r = 138 / 255, g = 185 / 255, b = 14 / 255})
end
function ml()
self.setColorTint({r = 130 / 255, g = 61 / 255, b = 163 / 255})
end
function ekehm()
self.setColorTint({r = 119 / 255, g = 146 / 255, b = 44 / 255})
end
local lineHeight = 30
local offset = 10
function onObjectPickUp(player_color, picked_up_object)
if picked_up_object.getGUID() == self.getGUID() then
--self.editButton(
-- {
-- index = 0,
-- label = self.getDescription()
-- }
--)
local label = self.getDescription()
self.UI.setAttribute("txt", "text", label)
if label == "" then
self.UI.setAttribute("bg", "color", "#ffffff00")
else
self.UI.setAttribute("bg", "color", "#ffffffaa")
if hasSecondLine(label) then
self.UI.setAttribute("bg", "height", tostring(lineHeight * 2))
else
self.UI.setAttribute("bg", "height", tostring(lineHeight))
end
end
end
end
function hasSecondLine(txt)
return string.find(txt, "\n") ~= nil
end