SHOW:
|
|
- or go back to the newest paste.
1 | --tEdit by Coolbob44 -- Version 2.0.0 -- Script Builder Version | |
2 | - | Player_Name = "coolbob44" |
2 | + | Player_Name = "DeltaDminor" |
3 | ||
4 | --------------------------------------------------------- | |
5 | ||
6 | plr=game.Players[Player_Name] | |
7 | repeat wait() until plr.Character | |
8 | ||
9 | function Create_PrivImpl(objectType) | |
10 | if type(objectType) ~= 'string' then | |
11 | error("Argument of Create must be a string", 2) | |
12 | end | |
13 | return function(dat) | |
14 | dat = dat or {} | |
15 | local obj = Instance.new(objectType) | |
16 | local ctor = nil | |
17 | for k, v in pairs(dat) do | |
18 | if type(k) == 'string' then | |
19 | obj[k] = v | |
20 | elseif type(k) == 'number' then | |
21 | if type(v) ~= 'userdata' then | |
22 | error("Bad entry in Create body: Numeric keys must be paired with children, got a: "..type(v), 2) | |
23 | end | |
24 | v.Parent = obj | |
25 | elseif type(k) == 'table' and k.__eventname then | |
26 | if type(v) ~= 'function' then | |
27 | error("Bad entry in Create body: Key `[Create.E\'"..k.__eventname.."\']` must have a function value\ | |
28 | got: "..tostring(v), 2) | |
29 | end | |
30 | obj[k.__eventname]:connect(v) | |
31 | elseif k == Create then | |
32 | if type(v) ~= 'function' then | |
33 | error("Bad entry in Create body: Key `[Create]` should be paired with a constructor function, \ | |
34 | got: "..tostring(v), 2) | |
35 | elseif ctor then | |
36 | error("Bad entry in Create body: Only one constructor function is allowed", 2) | |
37 | end | |
38 | ctor = v | |
39 | else | |
40 | error("Bad entry ("..tostring(k).." => "..tostring(v)..") in Create body", 2) | |
41 | end | |
42 | end | |
43 | if ctor then | |
44 | ctor(obj) | |
45 | end | |
46 | return obj | |
47 | end | |
48 | end | |
49 | Create = setmetatable({}, {__call = function(tb, ...) return Create_PrivImpl(...) end}) | |
50 | Create.E = function(eventName) | |
51 | return {__eventname = eventName} | |
52 | end | |
53 | ||
54 | if not script.Parent:IsA("HopperBin") then | |
55 | x = Instance.new("HopperBin") | |
56 | x.Parent = plr.Backpack | |
57 | x.Name = "tE 2" | |
58 | script.Parent = x | |
59 | else | |
60 | max_material = 17 | |
61 | points={} | |
62 | points_show = {} | |
63 | undo_hist={} | |
64 | redo_hist={} | |
65 | SC = {} | |
66 | mode = 1 | |
67 | images = { | |
68 | "http://www.roblox.com/asset/?id=33577919"; | |
69 | "http://www.roblox.com/asset/?id=56563112"; | |
70 | "http://www.roblox.com/asset/?id=62356652"; | |
71 | "http://www.roblox.com/asset/?id=65961537"; | |
72 | "http://www.roblox.com/asset/?id=67532153"; | |
73 | "http://www.roblox.com/asset/?id=67532038"; | |
74 | "http://www.roblox.com/asset/?id=67532093"; | |
75 | "http://www.roblox.com/asset/?id=67531995"; | |
76 | "http://www.roblox.com/asset/?id=67532118"; | |
77 | "http://www.roblox.com/asset/?id=67532015"; | |
78 | "http://www.roblox.com/asset/?id=67532051"; | |
79 | "http://www.roblox.com/asset/?id=67532206"; | |
80 | "http://www.roblox.com/asset/?id=67532103"; | |
81 | "http://www.roblox.com/asset/?id=67531804"; | |
82 | "http://www.roblox.com/asset/?id=67532059"; | |
83 | "http://www.roblox.com/asset/?id=67531848"; | |
84 | "http://www.roblox.com/asset/?id=67531924"; | |
85 | "http://www.roblox.com/asset/?id=81407474"; | |
86 | } | |
87 | modes = {"Set", "Replace", "Walls", "Outline", "Check"} | |
88 | sBox = Create'Model'{ | |
89 | Create'Part'{ | |
90 | Name = "One"; | |
91 | FormFactor = "Custom"; | |
92 | Size = Vector3.new(4,4,4); | |
93 | Transparency = 1; | |
94 | Anchored = true; | |
95 | CanCollide = false; | |
96 | Locked = true; | |
97 | }; | |
98 | Create'Part'{ | |
99 | Name = "Two"; | |
100 | FormFactor = "Custom"; | |
101 | Size = Vector3.new(4,4,4); | |
102 | Transparency = 1; | |
103 | Anchored = true; | |
104 | CanCollide = false; | |
105 | Locked = true; | |
106 | }; | |
107 | }; | |
108 | SelectionBox = Create'SelectionBox'{ | |
109 | Parent = plr.PlayerGui; | |
110 | Adornee = sBox; | |
111 | } | |
112 | ||
113 | function CreateGui() | |
114 | gui = Create'ScreenGui'{ | |
115 | Name = "tEdit 2"; | |
116 | Parent = nil; | |
117 | ||
118 | Create'TextButton'{ | |
119 | Name = "Frame"; | |
120 | Size = UDim2.new(0, 500, 0, 130); | |
121 | Position = UDim2.new(0.5, -250, 1, 10); | |
122 | Text = ""; | |
123 | Draggable = true; | |
124 | BackgroundTransparency = 1; | |
125 | ||
126 | Create'Frame'{ | |
127 | Size = UDim2.new(1,0,1,0); | |
128 | Style = "RobloxRound"; | |
129 | } | |
130 | } | |
131 | }; | |
132 | ||
133 | gmain = gui.Frame.Frame | |
134 | modebuttons = {} | |
135 | materialbuttons = {} | |
136 | mater = nil | |
137 | ||
138 | local modeBase = Create'TextButton'{ | |
139 | Size = UDim2.new(0, 100, 0, 20); | |
140 | Style = "RobloxButton"; | |
141 | TextColor3 = Color3.new(1,1,1); | |
142 | FontSize = "Size10"; | |
143 | } | |
144 | ||
145 | local matBase = Create'TextButton'{ | |
146 | Size = UDim2.new(0, 32, 0, 32); | |
147 | BackgroundColor3 = Color3.new(50/255, 50/255, 50/255); | |
148 | BorderSizePixel = 0; | |
149 | Text = ""; | |
150 | AutoButtonColor = false; | |
151 | ||
152 | Create'ImageLabel'{ | |
153 | Name = "Image"; | |
154 | Image = ""; | |
155 | Size = UDim2.new(0, 30, 0, 30); | |
156 | Position = UDim2.new(0, 1, 0, 1); | |
157 | BackgroundColor3 = Color3.new(80/255, 80/255, 80/255); | |
158 | BorderSizePixel = 0; | |
159 | BorderColor3 = Color3.new(1,0,0); | |
160 | BackgroundTransparency = 1; | |
161 | }; | |
162 | } | |
163 | ||
164 | local expandUp = Create'TextButton'{ | |
165 | Size = UDim2.new(0, 20, 0, 20); | |
166 | Style = "RobloxButton"; | |
167 | TextColor3 = Color3.new(1,1,1); | |
168 | Text = "+"; | |
169 | FontSize = "Size10"; | |
170 | Parent = gmain; | |
171 | Position = UDim2.new(0, 420, 0, 10); | |
172 | ||
173 | Create'TextLabel'{ | |
174 | TextXAlignment = "Right"; | |
175 | Position = UDim2.new(0, -10, 0, 5); | |
176 | Text = "Expand"; | |
177 | TextColor3 = Color3.new(1,1,1); | |
178 | }; | |
179 | }; | |
180 | ||
181 | local expandDown = Create'TextButton'{ | |
182 | Size = UDim2.new(0, 20, 0, 20); | |
183 | Style = "RobloxButton"; | |
184 | TextColor3 = Color3.new(1,1,1); | |
185 | Text = "-"; | |
186 | FontSize = "Size10"; | |
187 | Parent = gmain; | |
188 | Position = UDim2.new(0, 444, 0, 10); | |
189 | }; | |
190 | ||
191 | local shiftUp = Create'TextButton'{ | |
192 | Size = UDim2.new(0, 20, 0, 20); | |
193 | Style = "RobloxButton"; | |
194 | TextColor3 = Color3.new(1,1,1); | |
195 | Text = "+"; | |
196 | FontSize = "Size10"; | |
197 | Parent = gmain; | |
198 | Position = UDim2.new(0, 420, 0, 35); | |
199 | ||
200 | Create'TextLabel'{ | |
201 | TextXAlignment = "Right"; | |
202 | Position = UDim2.new(0, -10, 0, 5); | |
203 | Text = "Shift"; | |
204 | TextColor3 = Color3.new(1,1,1); | |
205 | }; | |
206 | }; | |
207 | ||
208 | local shiftDown = Create'TextButton'{ | |
209 | Size = UDim2.new(0, 20, 0, 20); | |
210 | Style = "RobloxButton"; | |
211 | TextColor3 = Color3.new(1,1,1); | |
212 | Text = "-"; | |
213 | FontSize = "Size10"; | |
214 | Parent = gmain; | |
215 | Position = UDim2.new(0, 444, 0, 35); | |
216 | }; | |
217 | ||
218 | local autoWedge = Create'TextButton'{ | |
219 | Size = UDim2.new(0, 30, 0, 20); | |
220 | Style = "RobloxButton"; | |
221 | TextColor3 = Color3.new(1,1,1); | |
222 | Text = "AW"; | |
223 | FontSize = "Size10"; | |
224 | Parent = gmain; | |
225 | Position = UDim2.new(0, 400, 0, 60); | |
226 | }; | |
227 | ||
228 | local noWedge = Create'TextButton'{ | |
229 | Size = UDim2.new(0, 30, 0, 20); | |
230 | Style = "RobloxButton"; | |
231 | TextColor3 = Color3.new(1,1,1); | |
232 | Text = "NW"; | |
233 | FontSize = "Size10"; | |
234 | Parent = gmain; | |
235 | Position = UDim2.new(0, 435, 0, 60); | |
236 | }; | |
237 | ||
238 | autoWedge.MouseButton1Click:connect(function() | |
239 | if not (points[1] and points[2]) then return end | |
240 | SC:AutoWedge(points[1], points[2]) | |
241 | end) | |
242 | ||
243 | noWedge.MouseButton1Click:connect(function() | |
244 | if not (points[1] and points[2]) then return end | |
245 | SC:NoWedge(points[1], points[2]) | |
246 | end) | |
247 | ||
248 | expandUp.MouseButton1Click:connect(function() | |
249 | if not (points[1] and points[2]) then return end | |
250 | PointsExpand(1, "u") | |
251 | end) | |
252 | ||
253 | expandDown.MouseButton1Click:connect(function() | |
254 | if not (points[1] and points[2]) then return end | |
255 | PointsExpand(-1, "u") | |
256 | end) | |
257 | ||
258 | shiftUp.MouseButton1Click:connect(function() | |
259 | if not (points[1] and points[2]) then return end | |
260 | PointsShift(1, "u") | |
261 | end) | |
262 | ||
263 | shiftDown.MouseButton1Click:connect(function() | |
264 | if not (points[1] and points[2]) then return end | |
265 | PointsShift(-1, "u") | |
266 | end) | |
267 | ||
268 | for i, v in pairs(modes) do | |
269 | local n = modeBase:Clone() | |
270 | n.Parent = gmain | |
271 | n.Position = UDim2.new(0, 5, 0, ((i-1)*22) + 7) | |
272 | n.Text = v | |
273 | if mode == i then | |
274 | n.Style = "RobloxButtonDefault" | |
275 | end | |
276 | n.MouseButton1Click:connect(function() | |
277 | for ie, ve in pairs(modebuttons) do | |
278 | ve.Style = "RobloxButton" | |
279 | end | |
280 | for ie, ve in pairs(materialbuttons) do | |
281 | ve.Visible = true | |
282 | mater = nil | |
283 | end | |
284 | n.Style = "RobloxButtonDefault" | |
285 | mode = i | |
286 | mater = nil | |
287 | end) | |
288 | modebuttons[#modebuttons+1] = n | |
289 | end | |
290 | ||
291 | local row = 0 | |
292 | local column = 0 | |
293 | ||
294 | for i, v in pairs(images) do | |
295 | row = row + 1 | |
296 | if row==8 then | |
297 | row = 1 | |
298 | column = column + 1 | |
299 | end | |
300 | local n = matBase:Clone() | |
301 | materialbuttons[#materialbuttons+1] = n | |
302 | n.Image.Image = v | |
303 | n.Position = UDim2.new(0, 90+(row*35), 0, (column*35)+10) | |
304 | n.Parent = gmain | |
305 | n.MouseEnter:connect(function() | |
306 | n.BackgroundColor3 = Color3.new(1,1,1) | |
307 | end) | |
308 | n.MouseLeave:connect(function() | |
309 | n.BackgroundColor3 = Color3.new(50/255, 50/255, 50/255) | |
310 | end) | |
311 | n.MouseButton1Click:connect(function() | |
312 | if not (points[1] and points[2]) then return end | |
313 | if mode == 1 then | |
314 | SC:Set(points[1], points[2], i-1) | |
315 | elseif mode == 2 then | |
316 | if mater then | |
317 | SC:Replace(points[1], points[2], i-1, mater) | |
318 | for ie, ve in pairs(materialbuttons) do | |
319 | ve.Visible = true | |
320 | end | |
321 | mater = nil | |
322 | else | |
323 | mater = i-1 | |
324 | n.Visible = false | |
325 | end | |
326 | elseif mode == 3 then | |
327 | SC:Walls(points[1], points[2], i-1) | |
328 | elseif mode == 4 then | |
329 | SC:Outline(points[1], points[2], i-1) | |
330 | elseif mode == 5 then | |
331 | if mater then | |
332 | SC:Set(points[1], points[2], i-1, true, mater) | |
333 | for ie, ve in pairs(materialbuttons) do | |
334 | ve.Visible = true | |
335 | end | |
336 | mater = nil | |
337 | else | |
338 | mater = i-1 | |
339 | n.Visible = false | |
340 | end | |
341 | end | |
342 | end) | |
343 | end | |
344 | ||
345 | return gui | |
346 | ||
347 | end | |
348 | ||
349 | function SC:Set(vec1, vec2, m, c, c2) | |
350 | local minX=math.min(vec1.x, vec2.x) | |
351 | local minY=math.min(vec1.y, vec2.y) | |
352 | local minZ=math.min(vec1.z, vec2.z) | |
353 | local maxX=math.max(vec1.x, vec2.x) | |
354 | local maxY=math.max(vec1.y, vec2.y) | |
355 | local maxZ=math.max(vec1.z, vec2.z) | |
356 | ||
357 | local x=minX | |
358 | local y=minY | |
359 | local z=minZ | |
360 | table.insert(undo_hist, 1, {}) | |
361 | while x <= maxX do | |
362 | local y=minY | |
363 | while y <= maxY do | |
364 | local z=minZ | |
365 | while z <= maxZ do | |
366 | local ci1, ci2, ci3 = Workspace.Terrain:GetCell(x, y, z) | |
367 | table.insert(undo_hist[1], 1, {Vector3.new(x, y, z), ci1, ci2, ci3}) | |
368 | if c then | |
369 | c3=z+x | |
370 | if c3%2==1 then | |
371 | Workspace.Terrain:SetCell(x, y, z, c2, 0, 1) | |
372 | else | |
373 | Workspace.Terrain:SetCell(x, y, z, m, 0, 1) | |
374 | end | |
375 | else | |
376 | Workspace.Terrain:SetCell(x, y, z, m, 0, 1) | |
377 | end | |
378 | ||
379 | z=z+1 | |
380 | end | |
381 | y=y+1 | |
382 | end | |
383 | x=x+1 | |
384 | end | |
385 | end | |
386 | function SC:NoWedge(vec1, vec2) | |
387 | local minX=math.min(vec1.x, vec2.x) | |
388 | local minY=math.min(vec1.y, vec2.y) | |
389 | local minZ=math.min(vec1.z, vec2.z) | |
390 | local maxX=math.max(vec1.x, vec2.x) | |
391 | local maxY=math.max(vec1.y, vec2.y) | |
392 | local maxZ=math.max(vec1.z, vec2.z) | |
393 | ||
394 | local x=minX | |
395 | local y=minY | |
396 | local z=minZ | |
397 | while x <= maxX do | |
398 | local y=minY | |
399 | while y <= maxY do | |
400 | local z=minZ | |
401 | while z <= maxZ do | |
402 | local cell,cellt,cello=Workspace.Terrain:GetCell(x, y, z) | |
403 | Workspace.Terrain:SetCell(x, y, z, 0, 0, 1) | |
404 | Workspace.Terrain:SetCell(x, y, z, cell, 0, 1) | |
405 | z=z+1 | |
406 | end | |
407 | y=y+1 | |
408 | end | |
409 | x=x+1 | |
410 | end | |
411 | end | |
412 | function SC:AutoWedge(vec1, vec2, m) | |
413 | local minX=math.min(vec1.x, vec2.x) | |
414 | local minY=math.min(vec1.y, vec2.y) | |
415 | local minZ=math.min(vec1.z, vec2.z) | |
416 | local maxX=math.max(vec1.x, vec2.x) | |
417 | local maxY=math.max(vec1.y, vec2.y) | |
418 | local maxZ=math.max(vec1.z, vec2.z) | |
419 | ||
420 | local x=minX | |
421 | local y=minY | |
422 | local z=minZ | |
423 | while x <= maxX do | |
424 | local y=minY | |
425 | while y <= maxY do | |
426 | local z=minZ | |
427 | while z <= maxZ do | |
428 | local cell,cellt,cello=Workspace.Terrain:GetCell(x, y, z) | |
429 | Workspace.Terrain:AutowedgeCell(x, y, z) | |
430 | z=z+1 | |
431 | end | |
432 | y=y+1 | |
433 | end | |
434 | x=x+1 | |
435 | end | |
436 | end | |
437 | function SC:Replace(vec1, vec2, m, r) | |
438 | local minX=math.min(vec1.x, vec2.x) | |
439 | local minY=math.min(vec1.y, vec2.y) | |
440 | local minZ=math.min(vec1.z, vec2.z) | |
441 | local maxX=math.max(vec1.x, vec2.x) | |
442 | local maxY=math.max(vec1.y, vec2.y) | |
443 | local maxZ=math.max(vec1.z, vec2.z) | |
444 | ||
445 | local x=minX | |
446 | local y=minY | |
447 | local z=minZ | |
448 | while x <= maxX do | |
449 | local y=minY | |
450 | while y <= maxY do | |
451 | local z=minZ | |
452 | while z <= maxZ do | |
453 | local cell,cellt,cello=Workspace.Terrain:GetCell(x, y, z) | |
454 | if cell==Enum.CellMaterial:GetEnumItems()[r+1] then | |
455 | Workspace.Terrain:SetCell(x, y, z, m, 0, 1) | |
456 | end | |
457 | z=z+1 | |
458 | end | |
459 | y=y+1 | |
460 | end | |
461 | x=x+1 | |
462 | end | |
463 | end | |
464 | function SC:Walls(vec1, vec2, m) | |
465 | local minX=math.min(vec1.x, vec2.x) | |
466 | local minY=math.min(vec1.y, vec2.y) | |
467 | local minZ=math.min(vec1.z, vec2.z) | |
468 | local maxX=math.max(vec1.x, vec2.x) | |
469 | local maxY=math.max(vec1.y, vec2.y) | |
470 | local maxZ=math.max(vec1.z, vec2.z) | |
471 | ||
472 | local x=minX | |
473 | local y=minY | |
474 | local z=minZ | |
475 | while x <= maxX do | |
476 | local y=minY | |
477 | local z=minZ | |
478 | while y <= maxY do | |
479 | Workspace.Terrain:SetCell(x, y, minZ, m, 0, 1) | |
480 | Workspace.Terrain:SetCell(x, y, maxZ, m, 0, 1) | |
481 | y=y+1 | |
482 | end | |
483 | x=x+1 | |
484 | end | |
485 | ||
486 | local x=minX | |
487 | local y=minY | |
488 | local z=minZ | |
489 | while y <= maxY do | |
490 | local z=minZ | |
491 | while z <= maxZ do | |
492 | Workspace.Terrain:SetCell(minX, y, z, m, 0, 1) | |
493 | Workspace.Terrain:SetCell(maxX, y, z, m, 0, 1) | |
494 | z=z+1 | |
495 | end | |
496 | y=y+1 | |
497 | end | |
498 | end | |
499 | function SC:Outline(vec1, vec2, m) | |
500 | local minX=math.min(vec1.x, vec2.x) | |
501 | local minY=math.min(vec1.y, vec2.y) | |
502 | local minZ=math.min(vec1.z, vec2.z) | |
503 | local maxX=math.max(vec1.x, vec2.x) | |
504 | local maxY=math.max(vec1.y, vec2.y) | |
505 | local maxZ=math.max(vec1.z, vec2.z) | |
506 | ||
507 | local x=minX | |
508 | local y=minY | |
509 | local z=minZ | |
510 | while x <= maxX do | |
511 | local y=minY | |
512 | local z=minZ | |
513 | while y <= maxY do | |
514 | Workspace.Terrain:SetCell(x, y, minZ, m, 0, 1) | |
515 | Workspace.Terrain:SetCell(x, y, maxZ, m, 0, 1) | |
516 | y=y+1 | |
517 | end | |
518 | x=x+1 | |
519 | end | |
520 | ||
521 | local x=minX | |
522 | local y=minY | |
523 | local z=minZ | |
524 | while y <= maxY do | |
525 | local z=minZ | |
526 | while z <= maxZ do | |
527 | Workspace.Terrain:SetCell(minX, y, z, m, 0, 1) | |
528 | Workspace.Terrain:SetCell(maxX, y, z, m, 0, 1) | |
529 | z=z+1 | |
530 | end | |
531 | y=y+1 | |
532 | end | |
533 | ||
534 | local x=minX | |
535 | local y=minY | |
536 | local z=minZ | |
537 | while z <= maxZ do | |
538 | local x=minX | |
539 | while x <= maxX do | |
540 | Workspace.Terrain:SetCell(x, minY, z, m, 0, 1) | |
541 | Workspace.Terrain:SetCell(x, maxY, z, m, 0, 1) | |
542 | x=x+1 | |
543 | end | |
544 | z=z+1 | |
545 | end | |
546 | end | |
547 | function undoLatest() | |
548 | if undo_hist[1] then | |
549 | table.insert(redo_hist, 1, {}) | |
550 | for i, v in pairs(undo_hist[1]) do | |
551 | local ci1, ci2, ci3 = Workspace.Terrain:GetCell(v[1].x, v[1].y, v[1].z) | |
552 | table.insert(redo_hist[1], 1, {Vector3.new(v[1].x, v[1].y, v[1].z), ci1, ci2, ci3}) | |
553 | Workspace.Terrain:SetCell(v[1].x, v[1].y, v[1].z, v[2], v[3], v[4]) | |
554 | end | |
555 | table.remove(undo_hist, 1) | |
556 | end | |
557 | end | |
558 | function redoLatest() | |
559 | if redo_hist[1] then | |
560 | table.insert(undo_hist, 1, {}) | |
561 | for i, v in pairs(redo_hist[1]) do | |
562 | local ci1, ci2, ci3 = Workspace.Terrain:GetCell(v[1].x, v[1].y, v[1].z) | |
563 | table.insert(undo_hist[1], 1, {Vector3.new(v[1].x, v[1].y, v[1].z), ci1, ci2, ci3}) | |
564 | Workspace.Terrain:SetCell(v[1].x, v[1].y, v[1].z, v[2], v[3], v[4]) | |
565 | end | |
566 | table.remove(redo_hist, 1) | |
567 | end | |
568 | end | |
569 | function PointsExpand(amt, dir) | |
570 | if dir=="u" then | |
571 | if points[1].y >= points[2].y then | |
572 | points[1]=points[1]+Vector3.new(0,amt,0) | |
573 | updateBox() | |
574 | else | |
575 | points[2]=points[2]+Vector3.new(0,amt,0) | |
576 | updateBox() | |
577 | end | |
578 | elseif dir=="d" then | |
579 | if points[1].y <= points[2].y then | |
580 | points[1]=points[1]-Vector3.new(0,amt,0) | |
581 | updateBox() | |
582 | else | |
583 | points[2]=points[2]-Vector3.new(0,amt,0) | |
584 | updateBox() | |
585 | end | |
586 | elseif dir=="vert" then | |
587 | points[1]=Vector3.new(points[1].x, 0, points[1].z) | |
588 | points[2]=Vector3.new(points[2].x, 62, points[2].z) | |
589 | updateBox() | |
590 | end | |
591 | end | |
592 | function updateBox() | |
593 | if points_show[1] and not points_show[2] then | |
594 | sBox.Parent = plr.Character | |
595 | SelectionBox.Parent = plr.PlayerGui | |
596 | sBox.One.CFrame = CFrame.new(Workspace.Terrain:CellCenterToWorld(points_show[1].x, points_show[1].y, points_show[1].z)) | |
597 | sBox.Two.CFrame = CFrame.new(Workspace.Terrain:CellCenterToWorld(points_show[1].x, points_show[1].y, points_show[1].z)) | |
598 | SelectionBox.Color = BrickColor.new("Really blue") | |
599 | elseif points[1] and not points[2] and points_show[2] then | |
600 | sBox.Parent = plr.Character | |
601 | SelectionBox.Parent = plr.PlayerGui | |
602 | sBox.One.CFrame = CFrame.new(Workspace.Terrain:CellCenterToWorld(points[1].x, points[1].y, points[1].z)) | |
603 | sBox.Two.CFrame = CFrame.new(Workspace.Terrain:CellCenterToWorld(points_show[2].x, points_show[2].y, points_show[2].z)) | |
604 | SelectionBox.Color = BrickColor.new("Lime green") | |
605 | elseif points[1] and points[2] then | |
606 | sBox.Parent = plr.Character | |
607 | SelectionBox.Parent = plr.PlayerGui | |
608 | sBox.One.CFrame = CFrame.new(Workspace.Terrain:CellCenterToWorld(points[1].x, points[1].y, points[1].z)) | |
609 | sBox.Two.CFrame = CFrame.new(Workspace.Terrain:CellCenterToWorld(points[2].x, points[2].y, points[2].z)) | |
610 | SelectionBox.Color = BrickColor.new("Really red") | |
611 | elseif points == {} and points_show == {} then | |
612 | sBox.Parent = nil | |
613 | SelectionBox.Parent = nil | |
614 | end | |
615 | end | |
616 | function PointsShift(amt, dir) | |
617 | if dir=="u" then | |
618 | ||
619 | points[1]=points[1]+Vector3.new(0,amt,0) | |
620 | points[2]=points[2]+Vector3.new(0,amt,0) | |
621 | updateBox() | |
622 | ||
623 | elseif dir=="d" then | |
624 | ||
625 | points[1]=points[1]-Vector3.new(0,amt,0) | |
626 | points[2]=points[2]-Vector3.new(0,amt,0) | |
627 | updateBox() | |
628 | ||
629 | end | |
630 | end | |
631 | function down(mouse) | |
632 | if mouse.Target ~= Workspace.Terrain then return end | |
633 | local point_terrain = Workspace.Terrain:WorldToCellPreferSolid(mouse.hit.p) | |
634 | if #points==0 or #points==2 then | |
635 | points = {point_terrain} | |
636 | points_show = {point_terrain} | |
637 | updateBox() | |
638 | else | |
639 | points[2]=point_terrain | |
640 | points_show[2] = point_terrain | |
641 | ||
642 | updateBox() | |
643 | end | |
644 | end | |
645 | function move(mouse) | |
646 | if mouse.Target ~= Workspace.Terrain then return end | |
647 | local point_terrain = Workspace.Terrain:WorldToCellPreferSolid(mouse.hit.p) | |
648 | if points[1] then | |
649 | points_show[2] = point_terrain | |
650 | else | |
651 | points_show[1] = point_terrain | |
652 | end | |
653 | updateBox() | |
654 | end | |
655 | function keyDown(k, mouse) | |
656 | if k=="c" then | |
657 | points = {} | |
658 | points_show = {} | |
659 | updateBox() | |
660 | move(mouse) | |
661 | elseif k=="r" then | |
662 | if mouse.Target ~= Workspace.Terrain then return end | |
663 | local point_terrain = Workspace.Terrain:WorldToCellPreferEmpty(mouse.hit.p) | |
664 | Workspace.Terrain:SetCell(point_terrain.x, point_terrain.y, point_terrain.z, 1, 0, 1) | |
665 | elseif k=="q" then | |
666 | if mouse.Target ~= Workspace.Terrain then return end | |
667 | local point_terrain = Workspace.Terrain:WorldToCellPreferSolid(mouse.hit.p) | |
668 | Workspace.Terrain:SetCell(point_terrain.x, point_terrain.y, point_terrain.z, 0, 0, 1) | |
669 | elseif k=="f" then | |
670 | if mouse.Target and plr.Character then | |
671 | plr.Character.Torso.CFrame = CFrame.new(mouse.hit.p+Vector3.new(0,3,0)) | |
672 | end | |
673 | end | |
674 | end | |
675 | plr.Chatted:connect(function(msg) | |
676 | if msg:lower():sub(1, 5) == "/set " then | |
677 | local mat=msg:sub(6) | |
678 | if tonumber(mat) and points[1] and points[2] then | |
679 | local mat=tonumber(mat) | |
680 | if mat < 0 or mat > max_material then return end | |
681 | SC:Set(points[1], points[2], mat) | |
682 | end | |
683 | print("Set to "..mat) | |
684 | elseif msg:lower():sub(1, 3) == "/aw" then | |
685 | if not points[1] or not points[2] then return end | |
686 | SC:AutoWedge(points[1], points[2]) | |
687 | print("Autowedged region") | |
688 | elseif msg:lower():sub(1, 7) == "/walls " then | |
689 | local mat=msg:sub(8) | |
690 | if tonumber(mat) and points[1] and points[2] then | |
691 | local mat=tonumber(mat) | |
692 | if mat < 0 or mat > max_material then return end | |
693 | SC:Walls(points[1], points[2], mat) | |
694 | end | |
695 | print("Set walls to "..mat) | |
696 | elseif msg:lower():sub(1, 9) == "/outline " then | |
697 | local mat=msg:sub(10) | |
698 | if tonumber(mat) and points[1] and points[2] then | |
699 | local mat=tonumber(mat) | |
700 | if mat < 0 or mat > max_material then return end | |
701 | SC:Outline(points[1], points[2], mat) | |
702 | end | |
703 | print("Outlined with "..mat) | |
704 | elseif msg:lower():sub(1, 9) == "/replace " then | |
705 | local matt=msg:sub(10) | |
706 | local del=matt:find(" ") | |
707 | if not del then return end | |
708 | mat=matt:sub(1, del-1) | |
709 | rep=matt:sub(del+1) | |
710 | if tonumber(mat) and tonumber(rep) and points[1] and points[2] then | |
711 | local mat=tonumber(mat) | |
712 | local rep=tonumber(rep) | |
713 | if mat < 0 or mat > max_material then return end | |
714 | if rep < 0 or rep > max_material then return end | |
715 | SC:Replace(points[1], points[2], rep, mat) | |
716 | end | |
717 | print("Successfully replaced "..rep.." with "..mat) | |
718 | elseif msg:lower():sub(1, 8) == "/expand " then | |
719 | local matt=msg:sub(9) | |
720 | local del=matt:find(" ") | |
721 | if not del then return end | |
722 | mat=matt:sub(1, del-1) | |
723 | dir=matt:sub(del+1) | |
724 | if tonumber(mat) and points[1] and points[2] then | |
725 | local mat=tonumber(mat) | |
726 | PointsExpand(mat, dir) | |
727 | end | |
728 | print("Expanded "..mat.." "..dir) | |
729 | elseif msg:lower():sub(1, 7) == "/check " then | |
730 | local matt=msg:sub(8) | |
731 | local del=matt:find(" ") | |
732 | if not del then return end | |
733 | mat=matt:sub(1, del-1) | |
734 | mat2=matt:sub(del+1) | |
735 | ||
736 | if tonumber(mat) and tonumber(mat2) and points[1] and points[2] then | |
737 | local mat=tonumber(mat) | |
738 | local mat2=tonumber(mat2) | |
739 | if mat < 0 or mat > max_material then return end | |
740 | if mat2 < 0 or mat2 > max_material then return end | |
741 | SC:Set(points[1], points[2], mat, true, mat2) | |
742 | end | |
743 | print("Checked selection with "..mat.." and "..mat2) | |
744 | elseif msg:lower():sub(1, 7) == "/shift " then | |
745 | local matt=msg:sub(8) | |
746 | local del=matt:find(" ") | |
747 | if not del then return end | |
748 | mat=matt:sub(1, del-1) | |
749 | dir=matt:sub(del+1) | |
750 | if tonumber(mat) and points[1] and points[2] then | |
751 | local mat=tonumber(mat) | |
752 | PointsShift(mat, dir) | |
753 | end | |
754 | print("Shifted "..mat.." "..dir) | |
755 | elseif msg:lower():sub(1, 6) == "/evert" then | |
756 | PointsExpand(nil, "vert") | |
757 | print("Region expanded") | |
758 | elseif msg:lower():sub(1, 3) == "/nw" then | |
759 | SCnw(points[1], points[2]) | |
760 | print("Unwedged") | |
761 | elseif msg:lower():sub(1, 5) == "/undo" then | |
762 | undoLatest() | |
763 | print("Undid") | |
764 | elseif msg:lower():sub(1, 5) == "/redo" then | |
765 | redoLatest() | |
766 | print("Redid") | |
767 | end | |
768 | end) | |
769 | function sel(mouse) | |
770 | gui = CreateGui() | |
771 | gui.Parent = plr.PlayerGui | |
772 | gui.Frame:TweenPosition(UDim2.new(0.5, -250, .7, 0), "Out", "Quad", 0.5, true) | |
773 | SelectionBox.Parent = plr.PlayerGui | |
774 | updateBox() | |
775 | move(mouse) | |
776 | mouse.Button1Down:connect(function() down(mouse) end) | |
777 | mouse.KeyDown:connect(function(k) keyDown(k, mouse) end) | |
778 | mouse.Move:connect(function() move(mouse) end) | |
779 | end | |
780 | function desel() | |
781 | points = {} | |
782 | points_show = {} | |
783 | SelectionBox.Parent = nil | |
784 | updateBox() | |
785 | if gui then gui.Frame:TweenPosition(UDim2.new(0.5, -250, 1, 5), "Out", "Quad", 0.5) game:service("Debris"):AddItem(gui, .5) end | |
786 | end | |
787 | script.Parent.Selected:connect(sel) | |
788 | script.Parent.Deselected:connect(desel) | |
789 | end |