Advertisement
ToxicTheBoss

dex addon v2

Mar 11th, 2020
11,883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.30 KB | None | 0 0
  1. -- // this is extremely inefficient but it works.
  2.  
  3. local s, e = pcall(function()
  4. local find = function()
  5. local cgui = game:GetService("CoreGui")
  6. for i, v in pairs(cgui:GetChildren()) do
  7. if v:FindFirstChild("ScriptEditor") then
  8. return v;
  9. end
  10. end
  11. return nil;
  12. end
  13.  
  14. local notify = function(msg)
  15. game.StarterGui:SetCore("SendNotification", {
  16. Title = "Notification:";
  17. Text = msg;
  18. Duration = 15;
  19. })
  20. end
  21.  
  22. if shared.gone then
  23. notify("You've already executed this!")
  24. while wait() do
  25. end
  26. end
  27.  
  28. local dex = find()
  29. local t = 0;
  30.  
  31. while not find() and wait() do
  32. t = t + 1
  33. end
  34.  
  35. if t >= 5 then -- means it took more than 5 seconds to find dex meaning this is most likely auto-execute now it will wait for dex to load.
  36. wait(3)
  37. end
  38.  
  39. dex = find();
  40.  
  41. notify("Loading script editor mod..")
  42.  
  43. local add = function(editor) -- adds the search ui btw
  44. local a=Instance.new("Frame")local b=Instance.new("TextBox")local c=Instance.new("UITextSizeConstraint")local d=Instance.new("TextLabel")local e=Instance.new("UITextSizeConstraint")local f=Instance.new("ImageButton")local g=Instance.new("ImageButton")local h=Instance.new("ImageButton")a.Name="Addon"a.Parent=editor;a.BackgroundColor3=Color3.fromRGB(30,30,30)a.BorderSizePixel=0;a.ClipsDescendants=true;a.Position=UDim2.new(0.548286617,0,0,0)a.Size=UDim2.new(0,275,0,30)a.ZIndex=100;b.Parent=a;b.AnchorPoint=Vector2.new(0.5,0.5)b.BackgroundColor3=Color3.fromRGB(50,50,50)b.BorderSizePixel=0;b.Position=UDim2.new(0.239772722,0,0.5,0)b.Size=UDim2.new(0.434545457,0,0.600000024,0)b.ZIndex=555;b.Font=Enum.Font.Code;b.PlaceholderText="Find"b.Text=""b.TextColor3=Color3.fromRGB(255,255,255)b.TextScaled=true;b.TextSize=14.000;b.TextWrapped=true;b.ClearTextOnFocus=false;c.Parent=b;c.MaxTextSize=13;d.Name="Amount"d.Parent=a;d.AnchorPoint=Vector2.new(0,0.5)d.BackgroundColor3=Color3.fromRGB(255,255,255)d.BackgroundTransparency=1.000;d.Position=UDim2.new(0.49454546,0,0.5,0)d.Size=UDim2.new(-0.534545481,200,1,0)d.ZIndex=100;d.Font=Enum.Font.Code;d.Text="3 of 5"d.TextColor3=Color3.fromRGB(255,255,255)d.TextScaled=true;d.TextSize=14.000;d.TextWrapped=true;e.Parent=d;e.MaxTextSize=15;f.Name="forward"f.Parent=a;f.AnchorPoint=Vector2.new(0.5,0.5)f.BackgroundTransparency=1.000;f.Position=UDim2.new(0.843636394,0,0.5,0)f.Size=UDim2.new(0,20,0,20)f.ZIndex=115;f.Image="rbxassetid://3926307971"f.ImageRectOffset=Vector2.new(564,284)f.ImageRectSize=Vector2.new(36,36)g.Name="back"g.Parent=a;g.AnchorPoint=Vector2.new(0.5,0.5)g.BackgroundTransparency=1.000;g.Position=UDim2.new(0.74909097,0,0.5,0)g.Size=UDim2.new(0,20,0,20)g.ZIndex=105;g.Image="rbxassetid://3926307971"g.ImageRectOffset=Vector2.new(124,324)g.ImageRectSize=Vector2.new(36,36)h.Name="close"h.Parent=a;h.AnchorPoint=Vector2.new(0,0.5)h.BackgroundTransparency=1.000;h.Position=UDim2.new(0.899999976,0,0.5,0)h.Size=UDim2.new(0,20,0,20)h.ZIndex=2000;h.Image="rbxassetid://3926305904"h.ImageRectOffset=Vector2.new(284,4)h.ImageRectSize=Vector2.new(24,24)return a
  45. end
  46.  
  47. if dex then
  48. shared.gone = true;
  49. local editor = dex.ScriptEditor.Editor;
  50. local tokens = dex.ScriptEditor.Editor.Container.TextArea.Tokens;
  51. local open = editor.Parent.OpenScript;
  52. local uis = game:GetService("UserInputService")
  53. local panel = add(editor)
  54. panel.Size = UDim2.new(panel.Size.X.Scale, panel.Size.X.Offset, 0, 0)
  55.  
  56. local close = function()
  57. panel:TweenSize(UDim2.new(panel.Size.X.Scale, panel.Size.X.Offset, 0, 0), Enum.EasingDirection.In, Enum.EasingStyle.Bounce, .35, true)
  58. end
  59.  
  60. local events = {
  61. getselection = function()
  62. local bindable = dex.ExplorerPanel.GetSelection;
  63. local items = bindable:Invoke();
  64. return items;
  65. end
  66. }
  67.  
  68. local looking = {
  69. [Enum.KeyCode.LeftControl] = true;
  70. [Enum.KeyCode.RightControl] = true;
  71. [Enum.KeyCode.F] = true;
  72. }
  73.  
  74. local ctrls = {
  75. [Enum.KeyCode.LeftControl] = true;
  76. [Enum.KeyCode.RightControl] = true;
  77. }
  78.  
  79. local data = {
  80. ["ctrl"] = false;
  81. ["f"] = false;
  82. }
  83.  
  84. local reset = function()
  85. for key, value in pairs(data) do
  86. data[key] = false;
  87. end
  88. end
  89.  
  90. local pullup = function()
  91. reset();
  92. if editor.Parent.Visible then
  93. panel:TweenSize(UDim2.new(panel.Size.X.Scale, panel.Size.X.Offset, 0, 30), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, .35, true)
  94. end
  95. spawn(function()
  96. wait(.35)
  97. panel.TextBox:CaptureFocus()
  98. end)
  99. end
  100.  
  101. local paneldata = {
  102. numbers = {
  103. at = 0;
  104. amount = 0;
  105. -- 0 of 0
  106. };
  107. results = {
  108. -- anything found via searching.
  109. }
  110. }
  111.  
  112. local textarea = editor.Container.TextArea
  113. local scanning = false;
  114. local panelopen = false;
  115.  
  116. local index = function(num)
  117. local s, e = pcall(function()
  118. if num == 0 then
  119. textarea.CanvasPosition = Vector2.new(0, 0)
  120. end
  121. local results = paneldata.results;
  122. if #results >= num then
  123. textarea.CanvasPosition = Vector2.new(0, results[num].Position.Y.Offset)
  124. else
  125. textarea.CanvasPosition = Vector2.new(0, 0)
  126. end
  127. end)
  128. end
  129.  
  130. local t = 0;
  131. local set = function()
  132. t = tick();
  133. local cur = t;
  134. end
  135.  
  136.  
  137. local last = '';
  138. local search = function(txt, b)
  139. if panelopen then
  140. local td = {}
  141. local c = tokens:GetChildren();
  142. for i = 1, #c do
  143. local item = c[i];
  144. if td[item.Text] then
  145. if item.Position == td[item.Text][1] then
  146. td[item.Text][2]:Destroy();
  147. end
  148. else
  149. td[item.Text] = {
  150. item.Position,
  151. item
  152. };
  153. end
  154. end
  155.  
  156. local s, e = pcall(function()
  157. for i = 1, #paneldata.results do
  158. local v = paneldata.results[i];
  159. v.BackgroundTransparency = 1;
  160. end
  161. if txt == '' then
  162. return false;
  163. end
  164. local results = {};
  165. last = txt;
  166. set()
  167. local current = t;
  168. paneldata.results = {}; -- resets to prevent any erroring.
  169. local children = tokens:GetChildren()
  170. local nextvalue = function(n, pre)
  171. local t = n.Text:lower();
  172. local lo = txt:lower();
  173. if t:sub(1, 1) == lo:sub(#pre + 1, #pre + 1) then
  174. return true;
  175. end
  176. return false;
  177. end
  178. for i = 1, #children do
  179. local value = children[i];
  180. if t == current then
  181. if value.Text:lower():find(txt:lower()) then
  182. table.insert(paneldata.results, value)
  183. -- ignore this, I was trying to filter through the next results to allow you to use stuff like require( in the search.
  184. --[[if nextvalue(children[i+1],value.Text) then
  185. table.insert(paneldata.results, children[i+1])
  186. end--]]
  187. end
  188. end
  189. end
  190. if t == current then
  191. paneldata.numbers.amount = #paneldata.results;
  192.  
  193. for i = 1, #paneldata.results do
  194. paneldata.results[i].BackgroundColor3 = Color3.fromRGB(255, 255, 0)
  195. paneldata.results[i].BackgroundTransparency = .5;
  196. end
  197. end
  198. end)
  199. end
  200. end
  201. panel.close.MouseButton1Click:Connect(function()
  202. panelopen = false;
  203. panel.TextBox.Text = '';
  204. paneldata.numbers.amount = 0;
  205. paneldata.numbers.at = 0;
  206.  
  207. local c = tokens:GetChildren()
  208. for i = 1, #tokens:GetChildren() do
  209. local v = c[i];
  210. v.BackgroundTransparency = 1;
  211. end
  212. close();
  213. end)
  214.  
  215. local add = function()
  216. local n = paneldata.numbers.at;
  217. local new = n + 1;
  218. if new < paneldata.numbers.amount or new == paneldata.numbers.amount then
  219. paneldata.numbers.at = n + 1;
  220. end
  221. end
  222.  
  223. local up = function()
  224. local nums = paneldata.numbers;
  225.  
  226. if nums.at == nums.amount then
  227. if nums.amount == 0 and nums.at == 0 then
  228. else
  229. add()
  230. end
  231. else
  232. add()
  233. end
  234. end
  235.  
  236. local back = function()
  237. local nums = paneldata.numbers;
  238. if nums.at == 0 then
  239. else
  240. paneldata.numbers.at = paneldata.numbers.at - 1;
  241. if paneldata.numbers.at == 0 and paneldata.numbers.amount >= 1 then
  242. paneldata.numbers.at = paneldata.numbers.at + 1;
  243. end
  244. end
  245. end
  246. panel.back.MouseButton1Click:Connect(function()
  247. back()
  248. end)
  249. panel.forward.MouseButton1Click:Connect(function()
  250. up()
  251. end)
  252. spawn(function()
  253. game:GetService('RunService').Heartbeat:Connect(function()
  254. local amount = paneldata.numbers.amount;
  255. local at = paneldata.numbers.at;
  256.  
  257. if at == 0 and amount == 0 then
  258. panel.Amount.Text = '';
  259. else
  260. panel.Amount.Text = at..' of '..amount
  261. end
  262. end)
  263. end)
  264.  
  265. local can = function(t)
  266. if #t >= 500 then
  267. notify("String is too long!")
  268. return false;
  269. end
  270. for i = 1, #t do
  271. if t:sub(i, i) == '' or t:sub(i, i) == ' ' then
  272. else
  273. return true;
  274. end
  275. end
  276. return false;
  277. end
  278. local val = Instance.new("IntValue")
  279. val.Name = 'Position'
  280. spawn(function()
  281. while wait() do
  282. val.Value = paneldata.numbers.at;
  283. if paneldata.numbers.amount == 0 then
  284. paneldata.numbers.at = 0;
  285. val.Value = paneldata.numbers.at
  286. end
  287. if panel.TextBox.Text == '' then
  288. paneldata.numbers.amount = 0;
  289. paneldata.numbers.at = 0;
  290. search('')
  291. end
  292. if paneldata.numbers.at == 0 and paneldata.numbers.amount >= 1 then
  293. paneldata.numbers.at = 1;
  294. end
  295. end
  296. end)
  297. val.Changed:Connect(function(n)
  298. if not scanning then
  299. index(val.Value)
  300. end
  301. end)
  302.  
  303. textarea.Changed:Connect(function()
  304. scanning = true;
  305. search(panel.TextBox.Text)
  306. wait(.1)
  307. scanning = false;
  308. end)
  309.  
  310. local last = textarea.CanvasPosition;
  311.  
  312. panel.TextBox.Changed:Connect(function()
  313. local txt = panel.TextBox.Text
  314. if can(txt) then
  315. search(txt)
  316. end
  317. end)
  318.  
  319. panel.TextBox.FocusLost:Connect(function(ep, random)
  320. if ep then
  321. wait()
  322. up();
  323. wait()
  324. panel.TextBox:CaptureFocus();
  325. end
  326. end)
  327.  
  328. local last;
  329.  
  330. uis.InputBegan:Connect(function(input, proccessed)
  331. if not proccessed then
  332. if input.KeyCode then
  333. if looking[input.KeyCode] then
  334. if not last or data.ctrl == true then
  335. if ctrls[input.KeyCode] then
  336. data.ctrl = true;
  337. else
  338. data.f = true;
  339. end
  340. if data.f and data.ctrl and input.KeyCode == Enum.KeyCode.F then
  341. panelopen = true;
  342. pullup()
  343. end
  344. else
  345. reset();
  346. end
  347. end
  348. end
  349. end
  350. end)
  351. else
  352. notify("Error")
  353. end
  354.  
  355. notify("Done! Enjoy :D")
  356. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement