blob: 6a13f5fad2395d11999858495072f8da3b525a82 (
plain) (
blame)
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
|
// implements some editing commands
//////// Entity Editing ///////////////
=enttype = [
|| [strcmp * $arg1] [strcmp (enttype) $arg1]
]
=entattr = [
|| [strcmp * $arg2] [= (entattr $arg1) $arg2]
]
// clear ents of given type
clearents = [
if $editing [
entcancel
entselect [ =enttype $arg1 ];
echo Deleted (enthavesel) $arg1 entities;
delent
]
]
// replace all ents that match current selection
// with the values given
replaceents = [
if $editing [
do [
entfind @(entget)
entset @(loopconcat i $numargs [result $[arg@(+ $i 1)]])
]
echo Replaced (enthavesel) entities
]
]
selentedit = [ saycommand ( concatword "/entset " (entget) ) ]
selreplaceents = [ saycommand ( concatword "/replaceents " (entget) ) ]
selentfindall = [ do [ entfind @(entget) ] ]
// modify given attribute of ent by a given amount
// arg1 attribute
// arg2 value
entproperty = [
entattr $arg1 (+ (entattr $arg1) $arg2)
]
enttypelist = [
light mapmodel playerstart particles sound
shells bullets rockets riflerounds grenades cartridges
health healthboost tinyhealth tinyarmour greenarmour yellowarmour quaddamage
teleport teledest jumppad
]
enttypeselect = [
enttypelength = (listlen $enttypelist)
next = (mod (+ (indexof $enttypelist (enttype)) $arg1) $enttypelength)
if (< $next 0) [ next = (+ $next $enttypelength) ]
do [entset @(listsplice (entget) (at $enttypelist $next) 0 1)]
]
////// Entity primary actions /////////
ent_action_teleport = [ entproperty 0 ( * $arg1 1 ) ]
ent_action_teledest = [ entproperty 1 ( * $arg1 1 ) ]
ent_action_mapmodel = [ entproperty 1 ( * $arg1 1 ) ]
ent_action_light = [ entproperty 0 ( * $arg1 5 ) ]
ent_action_jumppad = [ entproperty 0 ( * $arg1 5 ) ]
ent_action_playerstart = [ entproperty 0 ( * $arg1 15 ) ]
ent_action_particles = [ entproperty 0 ( * $arg1 1 ) ]
ent_action_sound = [ entproperty 0 ( * $arg1 1 ) ]
//////// Copy and Paste //////////////
// 3 types of copying and pasting
// 1. select only cubes -> paste only cubes
// 2. select cubes and ents -> paste cubes and ents. same relative positions
// 3. select only ents -> paste last selected ent. if ents are selected, replace attrs as paste
opaquepaste = 1
entcopybuf = ""
entreplace = [
do [
if (enthavesel) [] [ newent @entcopybuf ]
entset @entcopybuf
]
]
editcopy = [
if (|| [havesel] [! (enthavesel)]) [
entcopybuf = ""
entcopy
copy
] [
entcopybuf = (entget)
]
]
editpaste = [
cancelpaste = (! (|| [enthavesel] [havesel]));
if (strcmp "" $entcopybuf) [
pastehilite
reorient // temp; real fix will be in octaedit
onrelease [
if $opaquepaste delcube
paste
entpaste
if $cancelpaste [ cancelsel ]
]
] [
entreplace
if $cancelpaste [ cancelsel ]
]
]
/////// Selection ///////////////
// select ents with given properties
// '*' is wildcard
entfind = [
if (= $numargs 0) [
entselect 1
] [
entselect (concat [ && [=enttype @@arg1] ] (loopconcat i (- $numargs 1) [
result [ [=entattr @@i @@[arg@(+ $i 2)]] ]
]))
]
]
entfindinsel = [
if (= $numargs 0) [
entselect [ insel ]
] [
entselect (concat [ && [insel] [=enttype @@arg1] ] (loopconcat i (- $numargs 1) [
result [ [=entattr @@i @@[arg@(+ $i 2)]] ]
]))
]
]
lse = [
line = ""
count = 0
entloop [
line = ( concatword $line (entget) " " )
count = ( + $count 1 )
if (> $count 4) [
echo $line
line = ""
count = 0
]
]
if (> $count 0 ) [ echo $line ]
echo (enthavesel) entities selected
]
drag = [ dragging 1; onrelease [ dragging 0 ] ]
corners = [ selectcorners 1; dragging 1; onrelease [ selectcorners 0; dragging 0 ] ]
editmove = [ moving 1; onrelease [ moving 0 ]; result $moving ]
entdrag = [ entmoving 1; onrelease [entmoving 0]; result $entmoving ]
editdrag = [ cancelsel; || [entdrag] [ drag ] ]
selcorners = [ cancelsel; || [entdrag] [ corners ] ]
editextend = [ || [entdrag] [ selextend; reorient; editmove ] ]
editmovewith = [
if (havesel) [
|| [editmove] [ @arg1 ]
onrelease [ moving 0; dragging 0 ]
] [
@arg1
]
]
editmovecorner = [ editmovewith selcorners ]
editmovedrag = [ editmovewith editdrag ]
////// Other Editing commands /////////
editfacewentpush = [
if (|| [havesel] [! (enthavesel)] ) [
if $moving [
pushsel $arg1
] [
entcancel
editface $arg1 $arg2
]
] [
if $entmoving [ entpush $arg1 ] [ ent_action_@(enttype) $arg1 ]
]
]
entswithdirection = "playerstart teledest mapmodel"
entdirection = [
if ( && [enthavesel] [ = (havesel) 0 ] ) [
if (>= (indexof $entswithdirection (enttype)) 0) [
if (> $arg1 0) [
entproperty 0 $arg2
if (> (entattr 0) 360) [ entproperty 0 -360 ]
] [
entproperty 0 (- 0 $arg2)
if (< (entattr 0) 0) [ entproperty 0 360 ]
]
]
result 1
] [
result 0
]
]
editdel = [ if (! (enthavesel)) [delcube]; delent ]
editflip = [ flip; entflip ]
editrotate = [
|| [ entdirection $arg1 15 ] [
rotate $arg1
entrotate $arg1
]
]
editcut = [
if (moving 1) [
if (= $moving 1) [selsave]
onrelease [
moving 0
if (selmoved) [
selswap
copy; entcopy
delcube; delent
selrestore
paste; entpaste
]
]
]
]
edithud = [
format "%6^f7%7^f7gridpower ^f2%1 %2 %3 %4 %5" $gridpower (
if $allfaces [format "^f2allfaces"][format "^f4allfaces"]
)(
if $entediting [format "^f2entediting"][format "^f4entediting"]
)(
if $entselsnap [format "^f2entselsnap"][format "^f4entselsnap"]
)(
if $dropwaypoints [format "^f0dropwaypoints"][]
)(
if (enthavesel) [concat (entget) ":^f2" (enthavesel) "^f7selected^n"]
)
]
entcomplete = [ listcomplete $arg1 $enttypelist ]
entcomplete newent
entcomplete entfind
entcomplete clearents
listcomplete editmat "air clip noclip gameclip death alpha"
air = [ editmat air $arg1 ]
clip = [ editmat clip $arg1 ]
noclip = [ editmat noclip $arg1 ]
gameclip = [ editmat gameclip $arg1 ]
death = [ editmat death $arg1 ]
alpha = [ editmat alpha $arg1 ]
echovcolor = [echo ***vcolor (getvcolor $getseltex)]
echovrotate = [echo ***vrotate (getvrotate $getseltex)]
echovoffset = [echo ***voffset (getvoffset $getseltex)]
echovscroll = [echo ***vscroll (getvscroll $getseltex)]
echovscale = [echo ***vscale (getvscale $getseltex)]
echovlayer = [echo ***vlayer (getvlayer $getseltex)]
echovalpha = [echo ***valpha (getvalpha $getseltex)]
|