-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclaimvisualizer.lua
76 lines (65 loc) · 1.71 KB
/
claimvisualizer.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
-- claiming-heads/claimvisualizer.lua
-- /lua require('claiming-heads.claimvisualizer').showBorders(playername, center, width)
-- /lua cs=require('claiming-heads.claiming').getApplicableClaims(spell.owner.pos) for _,c in pairs(cs) do require('claiming-heads.claimvisualizer').showBorders(spell.owner.name, c.pos, c.width) end
local module = ...
local pkg = {}
local line
local rect
local log
function pkg.showBorders(playername, center, width)
if not playername then
error("missing playername")
end
local player = Entities.find("@a[name="..playername.."]")[1]
if not player then
error("player with name %s not found", playername)
end
if not center then
error("missing center")
end
if not width then
error("missing width")
end
local a = center + Vec3(width,0,width)
local b = center + Vec3(-width,0,-width)
local y=math.floor(player.pos.y)
for k=1,1 do
for i=-1,4 do
rect(a,b,y+i, player)
if k>1 then
sleep(20)
end
end
end
end
function line(a, b, player)
local delta = (b-a)
local dist = delta:magnitude()
local step = delta*(1/dist)
spell.pos = a
for i=0,dist do
spell:execute([[
/particle barrier ~0.5 ~-0.5 ~0.5 0 0 0 1 1 force %s
]], player.name)
spell.pos = spell.pos + step
end
end
function rect(a,b,y, player)
local a1 = Vec3(a.x,y,a.z)
local a2 = Vec3(b.x,y,a.z)
local a3 = Vec3(b.x,y,b.z)
local a4 = Vec3(a.x,y,b.z)
line(a1,a2, player)
line(a2,a3, player)
line(a3,a4, player)
line(a4,a1, player)
end
-- Logs the given message into the chat
function log(message, ...)
local n = select('#', ...)
if n>0 then
message = string.format(message, ...)
end
spell:execute("say %s", message)
end
return pkg