-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscript.lua
285 lines (256 loc) · 7.12 KB
/
script.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
--data api!!!
data.setName("Flace")
-- hide some vanilla stuff --
armor_model.HELMET.setEnabled(false)
vanilla_model.CAPE.setEnabled(false)
-- vector things --
vec = vectors.of
vec0 = vec{0, 0, 0}
vec3 = vec{1, 1, 1}
-- texture size --
texture = vec{128, 128} -- widgth, height
--variables --
time = 0
-- some model stuff --
animation.speeen.start()
animation.speeen.setSpeed(2)
model.Head.Het.setScale({1.4,1.4,1.4})
-- hats --
Hats = {
model.Head.Pineapple,
model.Head.GNHat,
model.Head.KFC_Bucket,
model.Head.Crown,
model.Head.BakerHat,
model.Head.WizardHat,
model.Head.MushroomHat,
model.Head.Het,
model.Head.EasterBasket,
model.Head.FryingPan
}
currentHat = tonumber(data.load("hat")) or 0
function setHat(x)
currentHat = x
for i, v in pairs(Hats) do
v.setEnabled(i == x)
end
end
function ping.switchHat(x)
data.save("hat", x)
ping.setHat(x)
end
function ping.setHat(x)
setHat(x)
end
setHat(currentHat)
-- pings --
a = function(x) print(x) end
pingsRefresh = {
tickDelay = 50,
{ping.setHat, _G, "currentHat"},
}
-- action wheel --
if client.isHost() then
local goToMain = {
Title = "Back to Main Page",
Function = function() setWheel("main") end,
Texture = "Custom",
UV = {48, 80, 16, 16, texture.x, texture.y},
}
action_wheel_folders = {
pages = {
page = 0,
name = "",
right = {
setTitle = "Next",
setFunction = function() setWheel(action_wheel_folders.pages.name, action_wheel_folders.pages.page+1) end,
Texture = "Custom",
setUV = {32, 80, 16, 16, texture.x, texture.y},
},
left = {
setTitle = "Previous",
setFunction = function() setWheel(action_wheel_folders.pages.name, action_wheel_folders.pages.page-1) end,
Texture = "Custom",
setUV = {48, 80, -16, 16, texture.x, texture.y},
},
first = {
setTitle = "You're on the first page",
Texture = "Custom",
setUV = {16, 80, 16, 16, texture.x, texture.y},
},
last = {
setTitle = "You're on the last page",
setFunction = function() end, setHoverColor = {255/255, 80/255, 120/255},
Texture = "Custom",
setUV = {16, 80, 16, 16, texture.x, texture.y},
}
},
main = {
{
Title = '{"text":"Hats","color":"#FF4488"},{"text":"!","color":"#FF88AA"}]',
Item = "leather_helmet{display:{color:16729258}}",
Function = function() setWheel("hats") end
}
},
hats = {
goToMain,
{
Title = '{"text":"Remove Hat","color":"#d43b3b"}',
Item = "barrier",
Function = {ping.switchHat, 0},
},
{
Title = '{"text":"Pineapple Hat","color":"#f5b622"}',
Texture = "Custom",
setUV = {0, 112, 16, 16, texture.x, texture.y},
Function = {ping.switchHat, 1},
},
{
Title = '{"text":"GNamimates Hat","color":"#39b54a"}',
Texture = "Custom",
setUV = {64, 112, 16, 16, texture.x, texture.y},
Function = {ping.switchHat, 2},
},
{
Title = '{"text":"KFC Bucket Hat","color":"#bb4356"}',
Texture = "Custom",
setUV = {16, 112, 16, 16, texture.x, texture.y},
Function = {ping.switchHat, 3},
},
{
Title = '{"text":"Crown Hat","color":"#ffeb4e"}',
Texture = "Custom",
setUV = {32, 112, 16, 16, texture.x, texture.y},
Function = {ping.switchHat, 4},
},
{
Title = '{"text":"Baker Hat","color":"#fef9ed"}',
Texture = "Custom",
setUV = {48, 112, 16, 16, texture.x, texture.y},
Function = {ping.switchHat, 5},
},
{
Title = '{"text":"Wizard Hat","color":"#222a82"}',
Texture = "Custom",
setUV = {96, 112, 16, 16, texture.x, texture.y},
Function = {ping.switchHat, 6},
},
{
Title = '{"text":"Mushroom Hat","color":"#ea5c42"}',
Texture = "Custom",
setUV = {80, 112, 16, 16, texture.x, texture.y},
Function = {ping.switchHat, 7},
},
{
Title = "Het",
Item = "stone",
Function = {ping.switchHat, 8},
},
{
Title = '{"text":"Easter Basket Hat","color":"#2fd1c5"}',
Texture = "Custom",
setUV = {32, 96, 16, 16, texture.x, texture.y},
Function = {ping.switchHat, 9},
},
{
Title = '{"text":"Frying Pan Hat","color":"#292b31"}',
Texture = "Custom",
setUV = {48, 96, 16, 16, texture.x, texture.y},
Function = {ping.switchHat, 10},
}
}
}
function setSlot(x, slot)
action_wheel["SLOT_"..slot].clear()
if not x then
return
end
action_wheel["SLOT_"..slot].setFunction(function() end)
for i, v in pairs(x) do
if i:sub(1, 3) ~= "set" then
i = "set"..i
end
if i == "setUV" then
action_wheel["SLOT_"..slot].setTextureScale(vec3/texture*16)
action_wheel["SLOT_"..slot].setUV({v[1], v[2]}, {v[3], v[4]}, {v[5], v[6]})
elseif i == "setFunction" and type(v) == "table" then
action_wheel["SLOT_"..slot].setFunction(v[1], v[2])
else
action_wheel["SLOT_"..slot][i](v)
end
end
end
function setWheel(wheel_folder, page)
if page == nil then
page = 0
end
if page < 0 or action_wheel_folders[wheel_folder][1+page*6] == nil then
return
end
action_wheel_folders.pages.name = wheel_folder
action_wheel_folders.pages.page = page
wheel_folder = action_wheel_folders[wheel_folder]
if #wheel_folder > 8 then
setSlot(action_wheel_folders.pages.right, 4)
setSlot(action_wheel_folders.pages.left, 5)
if (page-1) < 0 then
setSlot(action_wheel_folders.pages.first, 5)
end
if wheel_folder[7+page*6] == nil then
setSlot(action_wheel_folders.pages.last, 4)
end
for a = 1, 6 do
local slot = a+page*6
a = a-3
if a > 3 then
a = a + 2
end
a = (a-1)%8+1
setSlot(wheel_folder[slot], a)
end
else
for i = 1, 8 do
setSlot(wheel_folder[i], i)
end
end
end
setWheel("main")
end
-- tick --
function tick()
--variables--
time = time + 1
worldTime = world.getTime()
local player_name = player.getName()
--nameplate--
nameplate.ENTITY.setText(
rainbow_text("Flace", worldTime, 5, 10, 1):sub(1, -2)..
',"\n",'..
rainbow_text(player_name, worldTime + 3, 5, 10, 0.3):sub(2)
)
nameplate.ENTITY.setPos{0, currentHat == 0 and 0 or 0.4, 0}
--pings--
if time % pingsRefresh.tickDelay == 0 then
local ping_id = math.floor(time/pingsRefresh.tickDelay) % #pingsRefresh + 1
local value
if pingsRefresh[ping_id][2] and pingsRefresh[ping_id][3] then
value = pingsRefresh[ping_id][2][ pingsRefresh[ping_id][3] ]
end
pingsRefresh[ping_id][1](value)
end
end
function rainbow_text(text, time, speed, offset, saturation)
--[[
local function col(x, speed, offset)
local hue = time*speed+x*offset % 360
return string.format("#%X", vectors.rgbToINT(vectors.hsvToRGB({hue/360, 1, 1})))
end--]]
local json = '['
for i = 1, #text do
local char = text:sub(i,i)
local color = vectors.hsvToRGB{(time * speed + i * offset) / 360, saturation, 1} * 255
json = json .. '{"text": "'..char..'", "color": "'..string.format("#%02x%02x%02x", color.r, color.g, color.b)..'"},'
end
return json:sub(1, -2).."]"
end
--]]