XZTablets

TonicHubV1

Apr 15th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.63 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local mouse = player:GetMouse()
  3. local runService = game:GetService("RunService")
  4. --local lex = require(script.Lexer1)
  5. local lex = loadstring(game:HttpGet("https://pastebin.com/raw/vJeTbzJb"))()
  6.  
  7. --local create = require(script.CreateService)
  8. local create = loadstring(game:HttpGet("https://pastebin.com/raw/FWhQhCTS"))()
  9.  
  10. local ui = create:Init()
  11.  
  12. -- Windows
  13.  
  14. local tonicMainWindow = ui:CreatePrimaryWindow()
  15. local tonicScriptHub = ui:CreateSecondaryWindow()
  16. local tonicOptionHub = ui:CreateSecondaryWindow()
  17.  
  18. tonicScriptHub:ToggleVisibility()
  19. tonicOptionHub:ToggleVisibility()
  20.  
  21. -- Window Titles
  22.  
  23. local tonicMainWindowTitle = tonicMainWindow:AddTitle("Tonic Hub - v1.0.0", {Enabled = true, Text = "Tonic"})
  24. local tonicScriptHubTitle = tonicScriptHub:AddTitle("Script Hub", {Enabled = not true, Text = "Script"})
  25. local tonicOptionHubTitle = tonicOptionHub:AddTitle("Options", {Enabled = not true, Text = "Options"})
  26.  
  27. -- Main Window Container
  28.  
  29. local mainWindowContainer = tonicMainWindow:AddContainer(false)
  30. mainWindowContainer.Position = UDim2.new(0,0,0,30)
  31. mainWindowContainer.Size = UDim2.new(1,0,1,-30)
  32.  
  33. -- Main Window Script Container
  34.  
  35. local mainWindowScriptEditor = tonicMainWindow:AddContainer(true, true)
  36. mainWindowScriptEditor.Position = UDim2.new(0,5,0,5)
  37. mainWindowScriptEditor.Size = UDim2.new(0,650,0,269)
  38. mainWindowScriptEditor.BackgroundColor3 = Color3.fromRGB(31,31,31)
  39. mainWindowScriptEditor.Parent = mainWindowContainer
  40.  
  41. -- Main Window Script Tracker
  42.  
  43. local mainWindowScriptTracker = tonicMainWindow:AddContainer(false, false)
  44. mainWindowScriptTracker.Size = UDim2.new(0,50,1,0)
  45. mainWindowScriptTracker.BackgroundTransparency = 1
  46. mainWindowScriptTracker.Parent = mainWindowScriptEditor
  47.  
  48. local trackerLayout = Instance.new("UIListLayout")
  49. trackerLayout.Parent = mainWindowScriptTracker
  50.  
  51. local function renderLines(quantity)
  52.     for i,v in pairs(mainWindowScriptTracker:GetChildren()) do
  53.         if v:IsA("TextLabel") then
  54.             v:Destroy()
  55.         end
  56.     end
  57.     for i = 1, quantity do
  58.         local newLabel = tonicMainWindow:AddLabel(i)
  59.         newLabel.Parent = mainWindowScriptTracker
  60.     end
  61. end
  62.  
  63. renderLines(1)
  64.  
  65. -- Main Window Script Input
  66.  
  67. local mainWindowScriptInput
  68. mainWindowScriptInput = tonicMainWindow:AddInput(function(returned)
  69.     local textBounds = (mainWindowScriptInput.TextBounds.Y / 18)
  70.     renderLines(textBounds)
  71. end)
  72. mainWindowScriptInput.Size = UDim2.new(0,590,0,270)
  73. mainWindowScriptInput.Position = UDim2.new(0,50,0,0)
  74. mainWindowScriptInput.TextTransparency = 1
  75. mainWindowScriptInput.Parent = mainWindowScriptEditor
  76.  
  77. -- Main Window Options
  78.  
  79. local options = {
  80.     [1] = {
  81.         Name = "Tonic.lua",
  82.         Source = "print('helloWorld')"
  83.     },
  84.     [2] = {
  85.         Name = "Aussie.lua",
  86.         Source = "Aussie is awesome"
  87.     }
  88. }
  89.  
  90. -- Main Window Option Tree
  91.  
  92. local mainWindowOptions = tonicMainWindow:AddOptionTree(options, function(returned)
  93.     mainWindowScriptInput.Text = returned
  94.     local textBounds = (mainWindowScriptInput.TextBounds.Y / 18)
  95.     renderLines(textBounds)
  96. end)
  97. mainWindowOptions.Position = UDim2.new(0,660,0,5)
  98. mainWindowOptions.Size = UDim2.new(0,135,0,269)
  99. mainWindowOptions.Parent = mainWindowContainer
  100.  
  101. -- Script Hub Option Tree
  102.  
  103. local scriptHubScripts = {
  104.     [1] = {
  105.         Name = "Blade Throwing Simulator",
  106.         Source = 'loadstring(game:HttpGet("https://pastebin.com/raw/cSBL2431"))()'
  107.     },
  108.     [2] = {
  109.         Name = "Banning Simulator 2",
  110.         Source = 'loadstring(game:HttpGet("https://pastebin.com/raw/4RXTdpZN"))()'
  111.     }
  112. }
  113.  
  114. local scriptOptionContainer = tonicScriptHub:AddContainer(true, false)
  115. scriptOptionContainer.Size = UDim2.new(1,-10,0,239)
  116. scriptOptionContainer.Position = UDim2.new(0,5,0,35)
  117.  
  118. local scriptOptionTree = tonicScriptHub:AddOptionTree(scriptHubScripts, function(returned)
  119.     loadstring(returned)()
  120. end)
  121. scriptOptionTree.Size = UDim2.new(1,0,1,0)
  122. scriptOptionTree.Parent = scriptOptionContainer
  123.  
  124. -- Main Window Button Container
  125.  
  126. local mainWindowButtonContainer = tonicMainWindow:AddContainer(false)
  127. mainWindowButtonContainer.BackgroundTransparency = 1
  128. mainWindowButtonContainer.Position = UDim2.new(0,0,1,-47)
  129. mainWindowButtonContainer.Size = UDim2.new(1,0,0,46)
  130.  
  131. local buttonContainerGrid = Instance.new("UIGridLayout")
  132. buttonContainerGrid.CellPadding = UDim2.new(0,5,0,5)
  133. buttonContainerGrid.CellSize = UDim2.new(0,90,1,-10)
  134. buttonContainerGrid.HorizontalAlignment = Enum.HorizontalAlignment.Center
  135. buttonContainerGrid.VerticalAlignment = Enum.VerticalAlignment.Center
  136. buttonContainerGrid.Parent = mainWindowButtonContainer
  137.  
  138. -- Main Window Buttons [Execute, Clear, Save File, Options, Discord]
  139.  
  140. local executeButton = tonicMainWindow:AddButton("Execute", function()
  141.     loadstring(mainWindowScriptInput.Text)()
  142. end)
  143.  
  144. local clearButton = tonicMainWindow:AddButton("Clear", function()
  145.     mainWindowScriptInput.Text = ""
  146.     renderLines(1)
  147. end)
  148.  
  149. local saveButton = tonicMainWindow:AddButton("Save File", function()
  150.     local fileNames = {
  151.         "BoxBox",
  152.         "TonicBox",
  153.         "BoxTonic",
  154.         "RandomName",
  155.         "ThisIsTonic",
  156.         "BoxIsTonic",
  157.         "BoxBoxTonic",
  158.         "TonicTonicBox",
  159.         "TonicBoxTonic",
  160.         "ThisIsBox",
  161.         "ThisBoxTonic"
  162.     }
  163.     local chars = "abcdefghijklmnopqrstuvwxyz"
  164.     local chosen = fileNames[math.random(1, #fileNames)]
  165.     local chosen2 = ""
  166.     for i = 1, math.random(1, 3) do
  167.         local chosen3 = math.random(1, chars:len())
  168.         chosen2 = chosen2 .. chars:sub(chosen3, chosen3)
  169.     end
  170.     local filename = chosen..chosen2
  171.     print("Saving file: "..filename..".lua")
  172.     writefile(filename..".lua", mainWindowScriptInput.Text)
  173. end)
  174.  
  175. local optionButton = tonicMainWindow:AddButton("Options", function()
  176.     tonicOptionHub:ToggleVisibility()
  177. end)
  178.  
  179. local scriptHubButton = tonicMainWindow:AddButton("Script Hub", function()
  180.     tonicScriptHub:ToggleVisibility()
  181. end)
  182.  
  183. local discordButton = tonicMainWindow:AddButton("Discord", function()
  184.     print("Discord: xyzabcxyz")
  185. end)
  186.  
  187. -- Colour Rendering
  188.  
  189. local colourSettings = {
  190.     ["PrimaryWindow"] = Color3.fromRGB(47, 47, 47),
  191.     ["SecondaryWindow"] = Color3.fromRGB(47, 47, 47),
  192.     ["Container"] = Color3.fromRGB(35, 35, 35),
  193.     ["OptionTree"] = Color3.fromRGB(61, 61, 61),
  194.     ["TitleBar"] = Color3.fromRGB(61, 61, 61)
  195. }
  196.  
  197. function renderColours()
  198.     local uiElements = ui:GetDescendants()
  199.     for i,v in next, colourSettings do
  200.         for i2,v2 in pairs(uiElements) do
  201.             if v2.Name == i then
  202.                 v2.BackgroundColor3 = v
  203.             end
  204.         end
  205.     end
  206. end
  207.  
  208. -- Options Colours
  209.  
  210. -- PrimaryWindow
  211.  
  212. local colourContainer = tonicOptionHub:AddContainer(true, false)
  213. colourContainer.Size = UDim2.new(1,-10,0,35)
  214. colourContainer.Position = UDim2.new(0,5,0,35)
  215. colourContainer.BackgroundColor3 = Color3.fromRGB(53,53,53)
  216.  
  217. local colourGrid = Instance.new("UIGridLayout")
  218. colourGrid.CellPadding = UDim2.new(0,0,0,0)
  219. colourGrid.CellSize = UDim2.new(0,5,0,5)
  220. colourGrid.StartCorner = Enum.StartCorner.TopLeft
  221. colourGrid.Parent = colourContainer
  222.  
  223. for i = 1, 255 do
  224.     local color = Color3.fromRGB(i,i,i)
  225.     local colourButton = tonicOptionHub:AddColour(color, function(returned)
  226.         colourSettings.PrimaryWindow = returned
  227.         renderColours()
  228.     end)
  229.     colourButton.Parent = colourContainer
  230. end
  231.  
  232. -- Secondary Window
  233.  
  234. local colourContainer2 = tonicOptionHub:AddContainer(true, false)
  235. colourContainer2.Size = UDim2.new(1,-10,0,35)
  236. colourContainer2.Position = UDim2.new(0,5,0,70)
  237. colourContainer2.BackgroundColor3 = Color3.fromRGB(53,53,53)
  238.  
  239. local colourGrid2 = Instance.new("UIGridLayout")
  240. colourGrid2.CellPadding = UDim2.new(0,0,0,0)
  241. colourGrid2.CellSize = UDim2.new(0,5,0,5)
  242. colourGrid2.StartCorner = Enum.StartCorner.TopLeft
  243. colourGrid2.Parent = colourContainer2
  244.  
  245. for i = 1, 255 do
  246.     local color = Color3.fromRGB(i,i,i)
  247.     local colourButton2 = tonicOptionHub:AddColour(color, function(returned)
  248.         colourSettings.SecondaryWindow = returned
  249.         renderColours()
  250.     end)
  251.     colourButton2.Parent = colourContainer2
  252. end
  253.  
  254. -- Container
  255.  
  256. local colourContainer2a = tonicOptionHub:AddContainer(true, false)
  257. colourContainer2a.Size = UDim2.new(1,-10,0,35)
  258. colourContainer2a.Position = UDim2.new(0,5,0,105)
  259. colourContainer2a.BackgroundColor3 = Color3.fromRGB(53,53,53)
  260.  
  261. local colourGrid2a = Instance.new("UIGridLayout")
  262. colourGrid2a.CellPadding = UDim2.new(0,0,0,0)
  263. colourGrid2a.CellSize = UDim2.new(0,5,0,5)
  264. colourGrid2a.StartCorner = Enum.StartCorner.TopLeft
  265. colourGrid2a.Parent = colourContainer2a
  266.  
  267. for i = 1, 255 do
  268.     local color = Color3.fromRGB(i,i,i)
  269.     local colourButton2a = tonicOptionHub:AddColour(color, function(returned)
  270.         colourSettings.Container = returned
  271.         renderColours()
  272.     end)
  273.     colourButton2a.Parent = colourContainer2a
  274. end
  275.  
  276. -- Option Tree
  277.  
  278. local colourContainer2b = tonicOptionHub:AddContainer(true, false)
  279. colourContainer2b.Size = UDim2.new(1,-10,0,35)
  280. colourContainer2b.Position = UDim2.new(0,5,0,140)
  281. colourContainer2b.BackgroundColor3 = Color3.fromRGB(53,53,53)
  282.  
  283. local colourGrid2b = Instance.new("UIGridLayout")
  284. colourGrid2b.CellPadding = UDim2.new(0,0,0,0)
  285. colourGrid2b.CellSize = UDim2.new(0,5,0,5)
  286. colourGrid2b.StartCorner = Enum.StartCorner.TopLeft
  287. colourGrid2b.Parent = colourContainer2b
  288.  
  289. for i = 1, 255 do
  290.     local color = Color3.fromRGB(i,i,i)
  291.     local colourButton2b = tonicOptionHub:AddColour(color, function(returned)
  292.         colourSettings.OptionTree = returned
  293.         renderColours()
  294.     end)
  295.     colourButton2b.Parent = colourContainer2b
  296. end
  297.  
  298. -- TitleBar
  299.  
  300. local colourContainer2c = tonicOptionHub:AddContainer(true, false)
  301. colourContainer2c.Size = UDim2.new(1,-10,0,35)
  302. colourContainer2c.Position = UDim2.new(0,5,0,175)
  303. colourContainer2c.BackgroundColor3 = Color3.fromRGB(53,53,53)
  304.  
  305. local colourGrid2c = Instance.new("UIGridLayout")
  306. colourGrid2c.CellPadding = UDim2.new(0,0,0,0)
  307. colourGrid2c.CellSize = UDim2.new(0,5,0,5)
  308. colourGrid2c.StartCorner = Enum.StartCorner.TopLeft
  309. colourGrid2c.Parent = colourContainer2c
  310.  
  311. for i = 1, 255 do
  312.     local color = Color3.fromRGB(i,i,i)
  313.     local colourButton2c = tonicOptionHub:AddColour(color, function(returned)
  314.         colourSettings.TitleBar = returned
  315.         renderColours()
  316.     end)
  317.     colourButton2c.Parent = colourContainer2c
  318. end
  319.  
  320. scriptHubButton.Parent, executeButton.Parent, clearButton.Parent, saveButton.Parent, optionButton.Parent, discordButton.Parent = mainWindowButtonContainer, mainWindowButtonContainer, mainWindowButtonContainer, mainWindowButtonContainer, mainWindowButtonContainer, mainWindowButtonContainer
  321.  
  322. local target = mainWindowScriptInput
  323. local box = target
  324.  
  325. function render(text)
  326.     for i,v in pairs(target:GetChildren()) do
  327.         if v:IsA("TextLabel") then
  328.             v:Destroy()
  329.         end
  330.     end
  331.     local getTokens = (lex(text))
  332.     local tokens = {}
  333.     for i,v in pairs(getTokens) do
  334.         for i2,v2 in pairs(v) do
  335.             table.insert(tokens, v2)
  336.         end
  337.     end
  338.    
  339.     local colours = {
  340.         ["keyword"] = {
  341.             Colour = Color3.fromRGB(249,38,114),
  342.             Font = Enum.Font.SourceSansBold
  343.         },
  344.         ["operator"] = {
  345.             Colour = Color3.fromRGB(248,248,242),
  346.         },
  347.         ["number"] = {
  348.             Colour = Color3.fromRGB(174,129,255)
  349.         },
  350.         ["string_start"] = {
  351.             Colour = Color3.fromRGB(230,219,90),
  352.             Font = Enum.Font.SourceSansItalic
  353.         },
  354.         ["string_end"] = {
  355.             Colour = Color3.fromRGB(230,219,90),
  356.             Font = Enum.Font.SourceSansItalic
  357.         },
  358.         ["string"] = {
  359.             Colour = Color3.fromRGB(230,219,90),
  360.             Font = Enum.Font.SourceSansItalic
  361.         },
  362.         ["builtin"] = {
  363.             Colour = Color3.fromRGB(102,217,239),
  364.             Font = Enum.Font.SourceSansBold
  365.         },
  366.         ["comment"] = {
  367.             Colour = Color3.fromRGB(121,121,121),
  368.             Font = Enum.Font.SourceSansSemibold
  369.         }
  370.     }
  371.    
  372.     local position = UDim2.new(0,0,0,0)
  373.     local prevline = 0
  374.     local textsize = 18
  375.    
  376.     for i,v in pairs(tokens) do
  377.         local line = v.line
  378.         local text = v.data
  379.         local pos1 = v.posFirst
  380.         local pos2 = v.posLast
  381.         local ttype = v.type
  382.         local icheck = colours[ttype] and true or false
  383.         local ccheck
  384.         local fcheck
  385.         if icheck then
  386.             ccheck = colours[ttype].Colour and true or false
  387.             fcheck = colours[ttype].Font and true or false
  388.         else
  389.             ccheck = false
  390.             fcheck = false
  391.         end
  392.         local colour
  393.         local font
  394.         if ccheck then
  395.             colour = colours[ttype].Colour
  396.         else
  397.             colour = Color3.fromRGB(255,255,255)
  398.         end
  399.         if fcheck then
  400.             font = colours[ttype].Font
  401.         else
  402.             font = Enum.Font.SourceSans
  403.         end
  404.         if line ~= prevline then
  405.             position = UDim2.new(0,0,0,line*textsize)
  406.         end
  407.         local tlabel = Instance.new("TextLabel")
  408.         tlabel.Text = text
  409.         tlabel.TextSize = textsize
  410.         tlabel.TextColor3 = colour
  411.         tlabel.Font = font
  412.         tlabel.Position = position
  413.         tlabel.BackgroundTransparency = 1
  414.         tlabel.Parent = target
  415.         local tbounds = tlabel.TextBounds
  416.         tlabel.Size = UDim2.new(0,tbounds.x,0,20)
  417.         position = position + UDim2.new(0,tbounds.x,0,0)
  418.         prevline = line
  419.     end
  420. end
  421.  
  422. box:GetPropertyChangedSignal("Text"):Connect(function()
  423.     render(box.Text)
  424.     local textBounds = (mainWindowScriptInput.TextBounds.Y / 18)
  425.     renderLines(textBounds)
  426. end)
Add Comment
Please, Sign In to add comment