Date: 2021/04/06 13:57:41 UTC-07:00
Type: Diff Report
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
# +------------------------
# |
# | P o l y g o n T o o l
# |
# | Handy tool to make noted polygons.
# |
# +------------------------
#
# @author mcmonkey
# @date 2021/01/22
-# @denizen-build REL-1725
+# @denizen-build REL-1733
# @script-version 1.0
#
# Installation:
# Just put the script in your scripts folder and reload.
#
# Usage:
# Type command "/ptool" to get a polygon selector tool.
# While holding the tool, left click to start a selection and right click to expand the selection.
# Requires permission "polygontool.pool"
#
# Use "/pheight (y)" to expand the Y range of the polygon.
# Requires permission "polygontool.pheight"
#
# Use "/pnote [name]" to note your selected polygon as the name. For example, "/pnote myshop" adds noted polygon 'myshop'.
# Requires permission "polygontool.pnote"
#
# Use "/pshow" to show your current polygon selection.
# Requirers permission "polygontool.pshow"
#
# In a script or "/ex" command, use "<player.has_flag[ptool_selection]>" to check if the player has a selection.
# and "<player.flag[ptool_selection]>" to get the selected polygon.
#
# ---------------------------- END HEADER ----------------------------
polygon_tool_item:
type: item
debug: false
material: blaze_rod
display name: <gold><bold>Polygon Tool
enchantments:
- vanishing_curse:1
mechanisms:
hides: ENCHANTS
lore:
- - Left click to start a polygon selection.
- - Right click to add a corner to the polygon.
+ - <&7>Left click to start a polygon selection.
+ - <&7>Right click to add a corner to the polygon.
+ - <&7>Use <&b>/pheight <&7>to expand the vertical height.
ptool_command:
type: command
debug: false
name: ptool
aliases:
- polygontool
permission: polygontool.ptool
description: Gets a polygon tool.
usage: /ptool
script:
- give polygon_tool_item
- narrate "<green>Here's your polygon tool!"
pheight_command:
type: command
debug: false
name: pheight
aliases:
- polygonheight
permission: polygontool.pheight
description: Sets the vertical range of your polygon to include the specified Y-height (or your own height).
usage: /pheight (y)
script:
- if !<player.has_flag[ptool_selection]>:
- narrate "<red>You don't have any polygon selected."
- stop
- define y <context.args.get[1]||<player.location.y>>
- if !<[y].is_decimal>:
- narrate "<red>Y value must be a numbers."
- stop
- flag player ptool_selection:<player.flag[ptool_selection].include_y[<[y]>]>
- inject polygon_tool_status_task
- narrate "<green>Polygon heights updated to min <player.flag[ptool_selection].min_y.round_to[2]> max <player.flag[ptool_selection].max_y.round_to[2]>."
pnote_command:
type: command
debug: false
name: pnote
aliases:
- polygonnote
permission: polygontool.pnote
description: Notes your selected polygon.
usage: /pnote [name]
script:
- if !<player.has_flag[ptool_selection]>:
- narrate "<red>You don't have any polygon selected."
- stop
- if <context.args.size> != 1:
- narrate "<red>/pnote [name]"
- stop
- if <player.flag[ptool_selection].corners.size> < 3:
- narrate "<red>Your polygon needs more corners."
- stop
- note <player.flag[ptool_selection]> as:<context.args.get[1]>
- inject polygon_tool_status_task
- narrate "<green>Polygon <aqua><context.args.get[1]><green> noted with <[message]>."
pshow_command:
type: command
debug: false
name: pshow
aliases:
- polygonshow
permission: polygontool.pshow
description: Shows your selected polygon.
usage: /pshow
script:
- if !<player.has_flag[ptool_selection]>:
- narrate "<red>You don't have any polygon selected."
- stop
- inject polygon_tool_status_task
- narrate <[message]>
polygon_tool_status_task:
type: task
debug: false
script:
- # TODO
- define polygon <player.flag[ptool_selection]>
- define message "<green>Polygon selection: in <[polygon].world.name> from Y <[polygon].min_y.round_to[2]> to <[polygon].max_y.round_to[2]> with <[polygon].corners.size> corners"
- actionbar <[message]>
- if <[polygon].corners.size> >= 3:
# Loose approximation of the polygon's scale to prevent trying to spawn a trillion particles
- define approx_scale <[polygon].bounding_box.max.sub[<[polygon].bounding_box.min>].vector_length>
- if <[approx_scale]> < 200:
- playeffect effect:flame at:<[polygon].shell> offset:0 targets:<player> visibility:32
- if <[approx_scale]> < 1000:
- playeffect effect:barrier at:<[polygon].outline> offset:0 targets:<player> visibility:32
polygon_tool_world:
type: world
debug: false
events:
# Basic usage logic
on player left clicks block with:polygon_tool_item:
- if <context.location.material.name||air> == air:
- stop
- flag player ptool_selection:<list[<context.location>].to_polygon.include_y[<context.location.y.add[2]>]>
- inject polygon_tool_status_task
- determine cancelled
on player right clicks block with:polygon_tool_item:
- if <context.location.material.name||air> == air:
- stop
- if <player.has_flag[ptool_selection]>:
- if <player.flag[ptool_selection].world.name> != <context.location.world.name>:
- narrate "<&c>You must restart your selection by left clicking."
- stop
- flag player ptool_selection:<player.flag[ptool_selection].with_corner[<context.location>].include_y[<context.location.y>]>
- else:
- flag player ptool_selection:<list[<context.location>].to_polygon.include_y[<context.location.y.add[2]>]>
- inject polygon_tool_status_task
- determine cancelled
# Prevent misuse
on player drops polygon_tool_item:
- remove <context.entity>
on player clicks in inventory with:polygon_tool_item:
- inject locally abuse_prevention_click
on player drags polygon_tool_item in inventory:
- inject locally abuse_prevention_click
abuse_prevention_click:
- if <context.inventory.inventory_type> == player:
- stop
- if <context.inventory.inventory_type> == crafting:
- if <context.raw_slot||<context.raw_slots.numerical.first>> >= 6:
- stop
- determine passively cancelled
- inventory update
+