From f1e0073db4693e43ba06d839f1ff2c24fb6dbd91 Mon Sep 17 00:00:00 2001 From: Thomas G <62822072+Thomasluigi07@users.noreply.github.com> Date: Tue, 28 Jun 2022 18:46:18 +1000 Subject: [PATCH] Update 9 --- public/asset/9 | 659 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 544 insertions(+), 115 deletions(-) diff --git a/public/asset/9 b/public/asset/9 index a7b7c41..161c0e6 100644 --- a/public/asset/9 +++ b/public/asset/9 @@ -9,7 +9,7 @@ -- Utility functions + Globals local function WaitForChild(parent, childName) while parent:FindFirstChild(childName) == nil do - parent.ChildAdded:wait(0.03) + wait() end return parent[childName] end @@ -18,30 +18,10 @@ local function typedef(obj) return obj end -local function IsPhone() - local cGui = Game:GetService('CoreGui') - local rGui = WaitForChild(cGui, 'RobloxGui') - if rGui.AbsoluteSize.Y < 600 then - return true - end - return false -end - --- Users can use enough white spaces to spoof chatting as other players --- This function removes trailing and leading white spaces --- AFAIK, there is no reason for spam white spaces -local function StringTrim(str) - -- %S is whitespaces - -- When we find the first non space character defined by ^%s - -- we yank out anything in between that and the end of the string - -- Everything else is replaced with %1 which is essentially nothing - return (str:gsub("^%s*(.-)%s*$", "%1")) -end - -while Game.Players.LocalPlayer == nil do wait(0.03) end +while Game.Players.LocalPlayer == nil do wait() end local Player = Game.Players.LocalPlayer -while Player.Character == nil do wait(0.03) end +while Player.Character == nil do wait() end local RbxUtility = LoadLibrary('RbxUtility') local Gui = typedef(RbxUtility) local Camera = Game.Workspace.CurrentCamera @@ -112,10 +92,376 @@ local Input = { } --------------------------------------------------- +------------------ Chat class -------------------- +local Chat = { + ChatColors = { + BrickColor.new("Bright red"), + BrickColor.new("Bright blue"), + BrickColor.new("Earth green"), + BrickColor.new("Bright violet"), + BrickColor.new("Bright orange"), + BrickColor.new("Bright yellow"), + BrickColor.new("Light reddish violet"), + BrickColor.new("Brick yellow"), + }, + + Gui = nil, + Frame = nil, + RenderFrame = nil, + TapToChatLabel = nil, + ClickToChatButton = nil, + + ScrollingLock = false, + EventListener = nil, + + -- This is actually a ring buffer + -- Meaning at hitting the historyLength it wraps around + -- Reuses the text objects, so chat atmost uses 100 text objects + MessageQueue = {}, + + -- Stores all the values for configuring chat + Configuration = { + FontSize = Enum.FontSize.Size10, -- 10 is good + -- Also change this when you are changing the above, this is suboptimal but so is our interface to find FontSize + NumFontSize = 10, + HistoryLength = 50, -- stores up to 50 of the last chat messages for you to scroll through, + Size = UDim2.new(0.38, 0, 0.20, 0), + MessageColor = Color3.new(1, 1, 1), + XScale = 0.025, + LifeTime = 45, + Position = UDim2.new(0, 2, 0.05, 0), + DefaultTweenSpeed = 0.15, + }, + + -- This could be redone by just using the previous and next fields of the Queue + -- But the iterators cause issues, will be optimized later + SlotPositions_List = {}, + -- To precompute and store all player null strings since its an expensive process + CachedSpaceStrings_List = {}, + MouseOnFrame = false, + GotFocus = false, + + SafeChat_List = { + ['Use the Chat menu to talk to me.'] = {'/sc 0', true}, + ['I can only see menu chats.'] = {'/sc 1', true}, + ['Hello'] = { + ['Hi'] = {'/sc 2_0', true, ['Hi there!'] = true, ['Hi everyone'] = true}, + ['Howdy'] = {'/sc 2_1', true, ['Howdy partner!'] = true}, + ['Greetings'] = {'/sc 2_2', true, ['Greetings everyone'] = true, ['Greetings Robloxians!'] = true, ['Seasons greetings!'] = true}, + ['Welcome'] = {'/sc 2_3', true, ['Welcome to my place'] = true, ['Welcome to my barbeque'] = true, ['Welcome to our base'] = true}, + ['Hey there!'] = {'/sc 2_4', true}, + ['What\'s up?'] = {'/sc 2_5', true, ['How are you doing?'] = true, ['How\'s it going?'] = true, ['What\'s new?'] = true}, + ['Good day'] = {'/sc 2_6', true, ['Good morning'] = true, ['Good evening'] = true, ['Good afternoon'] = true, ['Good night'] = true}, + ['Silly'] = {'/sc 2_7', true, ['Waaaaaaaz up?!'] = true, ['Hullo!'] = true, ['Behold greatness, mortals!'] = true, ['Pardon me, is this Sparta?'] = true, ['THIS IS SPARTAAAA!'] = true}, + ['Happy Holidays!'] = {'/sc 2_8', true, ['Happy New Year!'] = true, + ['Happy Valentine\'s Day!'] = true, + ['Beware the Ides of March!'] = true, + ['Happy St. Patrick\'s Day!'] = true, + ['Happy Easter!'] = true, + ['Happy Earth Day!'] = true, + ['Happy 4th of July!'] = true, + ['Happy Thanksgiving!'] = true, + ['Happy Halloween!'] = true, + ['Happy Hanukkah!'] = true, + ['Merry Christmas!'] = true, + ['Happy Halloween!'] = true, + ['Happy Earth Day!'] = true, + ['Happy May Day!'] = true, + ['Happy Towel Day!'] = true, + ['Happy ROBLOX Day!'] = true, + ['Happy LOL Day!'] = true }, + + [1] = '/sc 2' + }, + ['Goodbye'] = { + ['Good Night']= {'/sc 3_0', true, + ['Sweet dreams'] = true, + ['Go to sleep!'] = true, + ['Lights out!'] = true, + ['Bedtime'] = true, + ['Going to bed now'] = true}, + + ['Later']= {'/sc 3_1', true, + ['See ya later'] = true, + ['Later gator!'] = true, + ['See you tomorrow'] = true}, + + ['Bye'] = {'/sc 3_2', true, ['Hasta la bye bye!'] = true}, + ['I\'ll be right back'] = {'/sc 3_3', true}, + ['I have to go'] = {'/sc 3_4', true}, + ['Farewell'] = {'/sc 3_5', true, ['Take care'] = true, ['Have a nice day'] = true, ['Goodluck!'] = true, ['Ta-ta for now!'] = true}, + ['Peace'] = {'/sc 3_6', true, ['Peace out!'] = true, ['Peace dudes!'] = true, ['Rest in pieces!'] = true}, + ['Silly'] = {'/sc 3_7', true, + ['To the batcave!'] = true, + ['Over and out!'] = true, + ['Happy trails!'] = true, + ['I\'ve got to book it!'] = true, + ['Tootles!'] = true, + ['Smell you later!'] = true, + ['GG!'] = true, + ['My house is on fire! gtg.'] = true}, + [1] = '/sc 3' + }, + ['Friend'] ={ + ['Wanna be friends?'] = {'/sc 4_0', true}, + ['Follow me'] = {'/sc 4_1', true, ['Come to my place!'] = true, ['Come to my base!'] = true, ['Follow me, team!'] = true, ['Follow me'] = true}, + ['Your place is cool'] = {'/sc 4_2', true, ['Your place is fun'] = true, ['Your place is awesome'] = true, ['Your place looks good'] = true, ['This place is awesome!'] = true}, + ['Thank you'] = {'/sc 4_3', true, ['Thanks for playing'] = true, ['Thanks for visiting'] = true, ['Thanks for everything'] = true, ['No, thank you'] = true, ['Thanx'] = true}, + ['No problem'] = {'/sc 4_4', true, ['Don\'t worry'] = true, ['That\'s ok'] = true, ['np'] = true}, + ['You are ...'] = {'/sc 4_5', true, + ['You are great!'] = true, + ['You are good!'] = true, + ['You are cool!'] = true, + ['You are funny!'] = true, + ['You are silly!'] = true, + ['You are awesome!'] = true, + ['You are doing something I don\'t like, please stop'] = true + }, + ['I like ...'] = {'/sc 4_6', true, ['I like your name'] = true, ['I like your shirt'] = true, ['I like your place'] = true, ['I like your style'] = true, + ['I like you'] = true, ['I like items'] = true, ['I like money'] = true}, + ['Sorry'] = {'/sc 4_7', true, ['My bad!'] = true, ['I\'m sorry'] = true, ['Whoops!'] = true, ['Please forgive me.'] = true, ['I forgive you.'] = true, + ['I didn\'t mean to do that.'] = true, ['Sorry, I\'ll stop now.'] = true}, + [1] = '/sc 4' + }, + ['Questions'] = { + ['Who?'] = {'/sc 5_0', true, ['Who wants to be my friend?'] = true, ['Who wants to be on my team?'] = true, ['Who made this brilliant game?'] = true}, + ['What?'] = {'/sc 5_1', true, ['What is your favorite animal?'] = true, ['What is your favorite game?'] = true, ['What is your favorite movie?'] = true, + ['What is your favorite TV show?'] = true, ['What is your favorite music?'] = true, ['What are your hobbies?'] = true, ['LOLWUT?'] = true}, + ['When?'] = {'/sc 5_2', true, ['When are you online?'] = true, ['When is the new version coming out?'] = true, ['When can we play again?'] = true, ['When will your place be done?'] = true}, + ['Where?'] = {'/sc 5_3', true, ['Where do you want to go?'] = true, ['Where are you going?'] = true, ['Where am I?!'] = true, ['Where did you go?'] = true}, + ['How?'] = {'/sc 5_4', true, ['How are you today?'] = true, ['How did you make this cool place?'] = true, ['LOLHOW?'] = true}, + ['Can I...'] = {'/sc 5_5', true, ['Can I have a tour?'] = true, ['Can I be on your team?'] = true, ['Can I be your friend?'] = true, ['Can I try something?'] = true, + ['Can I have that please?'] = true, ['Can I have that back please?'] = true, ['Can I have borrow your hat?'] = true, ['Can I have borrow your gear?'] = true}, + [1] = '/sc 5' + }, + ['Answers'] = { + ['You need help?'] = {'/sc 6_0', true, ['Check out the news section'] = true, ['Check out the help section'] = true, ['Read the wiki!'] = true, + ['All the answers are in the wiki!'] = true, ['I will help you with this.'] = true}, + ['Some people ...'] = {'/sc 6_1', true, ['Me'] = true, ['Not me'] = true, ['You'] = true, ['All of us'] = true, ['Everyone but you'] = true, ['Builderman!'] = true, + ['Telamon!'] = true, ['My team'] = true, ['My group'] = true, ['Mom'] = true, ['Dad'] = true, ['Sister'] = true, ['Brother'] = true, ['Cousin'] = true, + ['Grandparent'] = true, ['Friend'] = true}, + ['Time ...'] = {'/sc 6_2', true, ['In the morning'] = true, ['In the afternoon'] = true, ['At night'] = true, ['Tomorrow'] = true, ['This week'] = true, ['This month'] = true, + ['Sometime'] = true, ['Sometimes'] = true, ['Whenever you want'] = true, ['Never'] = true, ['After this'] = true, ['In 10 minutes'] = true, ['In a couple hours'] = true, + ['In a couple days'] = true}, + ['Animals'] = {'/sc 6_3', true, + ['Cats'] = {['Lion'] = true, ['Tiger'] = true, ['Leopard'] = true, ['Cheetah'] = true}, + ['Dogs'] = {['Wolves'] = true, ['Beagle'] = true, ['Collie'] = true, ['Dalmatian'] = true, ['Poodle'] = true, ['Spaniel'] = true, + ['Shepherd'] = true, ['Terrier'] = true, ['Retriever'] = true}, + ['Horses'] = {['Ponies'] = true, ['Stallions'] = true, ['Pwnyz'] = true}, + ['Reptiles'] = {['Dinosaurs'] = true, ['Lizards'] = true, ['Snakes'] = true, ['Turtles!'] = true}, + ['Hamster'] = true, + ['Monkey'] = true, + ['Bears'] = true, + ['Fish'] = {['Goldfish'] = true, ['Sharks'] = true, ['Sea Bass'] = true, ['Halibut'] = true, ['Tropical Fish'] = true}, + ['Birds'] = {['Eagles'] = true, ['Penguins'] = true, ['Parakeets'] = true, ['Owls'] = true, ['Hawks'] = true, ['Pidgeons'] = true}, + ['Elephants'] = true, + ['Mythical Beasts'] = {['Dragons'] = true, ['Unicorns'] = true, ['Sea Serpents'] = true, ['Sphinx'] = true, ['Cyclops'] = true, + ['Minotaurs'] = true, ['Goblins'] = true, ['Honest Politicians'] = true, ['Ghosts'] = true, ['Scylla and Charybdis'] = true} + }, + ['Games'] = {'/sc 6_4', true, + ['Action'] = true, ['Puzzle'] = true, ['Strategy'] = true, ['Racing'] = true, ['RPG'] = true, ['Obstacle Course'] = true, ['Tycoon'] = true, + ['Roblox'] = { ['BrickBattle'] = true, ['Community Building'] = true, ['Roblox Minigames'] = true, ['Contest Place'] = true}, + ['Board games'] = { ['Chess'] = true, ['Checkers'] = true, ['Settlers of Catan'] = true, ['Tigris and Euphrates'] = true, ['El Grande'] = true, + ['Stratego'] = true, ['Carcassonne'] = true} + }, + ['Sports'] = {'/sc 6_5', true, ['Hockey'] = true, ['Soccer'] = true, ['Football'] = true, ['Baseball'] = true, ['Basketball'] = true, + ['Volleyball'] = true, ['Tennis'] = true, ['Sports team practice'] = true, + ['Watersports'] = { ['Surfing'] = true,['Swimming'] = true, ['Water Polo'] = true}, + ['Winter sports'] = { ['Skiing'] = true, ['Snowboarding'] = true, ['Sledding'] = true, ['Skating'] = true}, + ['Adventure'] = {['Rock climbing'] = true, ['Hiking'] = true, ['Fishing'] = true, ['Horseback riding'] = true}, + ['Wacky'] = {['Foosball'] = true, ['Calvinball'] = true, ['Croquet'] = true, ['Cricket'] = true, ['Dodgeball'] = true, + ['Squash'] = true, ['Trampoline'] = true} + }, + ['Movies/TV'] = {'/sc 6_6', true, ['Science Fiction'] = true, ['Animated'] = {['Anime'] = true}, ['Comedy'] = true, ['Romantic'] = true, + ['Action'] = true, ['Fantasy'] = true}, + ['Music'] = {'/sc 6_7', true, ['Country'] = true, ['Jazz'] = true, ['Rap'] = true, ['Hip-hop'] = true, ['Techno'] = true, ['Classical'] = true, + ['Pop'] = true, ['Rock'] = true}, + ['Hobbies'] = {'/sc 6_8', true, + ['Computers'] = { ['Building computers'] = true, ['Videogames'] = true, ['Coding'] = true, ['Hacking'] = true}, + ['The Internet'] = { ['lol. teh internets!'] = true, ['Watching vids'] = true}, + ['Dance'] = true, ['Gymnastics'] = true, ['Listening to music'] = true, ['Arts and crafts'] = true, + ['Martial Arts'] = {['Karate'] = true, ['Judo'] = true, ['Taikwon Do'] = true, ['Wushu'] = true, ['Street fighting'] = true}, + ['Music lessons'] = {['Playing in my band'] = true, ['Playing piano'] = true, ['Playing guitar'] = true, + ['Playing violin'] = true, ['Playing drums'] = true, ['Playing a weird instrument'] = true} + }, + ['Location'] = {'/sc 6_9', true, + ['USA'] = { + ['West'] = { ['Alaska'] = true, ['Arizona'] = true, ['California'] = true, ['Colorado'] = true, ['Hawaii'] = true, + ['Idaho'] = true, ['Montana'] = true, ['Nevada'] = true, ['New Mexico'] = true, ['Oregon'] = true, + ['Utah'] = true, ['Washington'] = true, ['Wyoming'] = true + }, + ['South'] = { ['Alabama'] = true, ['Arkansas'] = true, ['Florida'] = true, ['Georgia'] = true, ['Kentucky'] = true, + ['Louisiana'] = true, ['Mississippi'] = true, ['North Carolina'] = true, ['Oklahoma'] = true, + ['South Carolina'] = true, ['Tennessee'] = true, ['Texas'] = true, ['Virginia'] = true, ['West Virginia'] = true + }, + ['Northeast'] = {['Connecticut'] = true, ['Delaware'] = true, ['Maine'] = true, ['Maryland'] = true, ['Massachusetts'] = true, + ['New Hampshire'] = true, ['New Jersey'] = true, ['New York'] = true, ['Pennsylvania'] = true, ['Rhode Island'] = true, + ['Vermont'] = true + }, + ['Midwest'] = {['Illinois'] = true, ['Indiana'] = true, ['Iowa'] = true, ['Kansas'] = true, ['Michigan'] = true, ['Minnesota'] = true, + ['Missouri'] = true, ['Nebraska'] = true, ['North Dakota'] = true, ['Ohio'] = true, ['South Dakota'] = true, ['Wisconsin'] = true} + }, + ['Canada'] = {['Alberta'] = true, ['British Columbia'] = true, ['Manitoba'] = true, ['New Brunswick'] = true, ['Newfoundland'] = true, + ['Northwest Territories'] = true, ['Nova Scotia'] = true, ['Nunavut'] = true, ['Ontario'] = true, ['Prince Edward Island'] = true, + ['Quebec'] = true, ['Saskatchewan'] = true, ['Yukon'] = true}, + ['Mexico'] = true, + ['Central America'] = true, + ['Europe'] = {['France'] = true, ['Germany'] = true, ['Spain'] = true, ['Italy'] = true, ['Poland'] = true, ['Switzerland'] = true, + ['Greece'] = true, ['Romania'] = true, ['Netherlands'] = true, + ['Great Britain'] = {['England'] = true, ['Scotland'] = true, ['Wales'] = true, ['Northern Ireland'] = true} + }, + ['Asia'] = { ['China'] = true, ['India'] = true, ['Japan'] = true, ['Korea'] = true, ['Russia'] = true, ['Vietnam'] = true}, + ['South America'] = { ['Argentina'] = true, ['Brazil'] = true}, + ['Africa'] = { ['Eygpt'] = true, ['Swaziland'] = true}, + ['Australia'] = true, ['Middle East'] = true, ['Antarctica'] = true, ['New Zealand'] = true + }, + ['Age'] = {'/sc 6_10', true, ['Rugrat'] = true, ['Kid'] = true, ['Tween'] = true, ['Teen'] = true, ['Twenties'] = true, + ['Old'] = true, ['Ancient'] = true, ['Mesozoic'] = true, ['I don\'t want to say my age. Don\'t ask.'] = true}, + ['Mood'] = {'/sc 6_11', true, ['Good'] = true, ['Great!'] = true, ['Not bad'] = true, ['Sad'] = true, ['Hyper'] = true, + ['Chill'] = true, ['Happy'] = true, ['Kind of mad'] = true}, + ['Boy'] = {'/sc 6_12', true}, + ['Girl'] = {'/sc 6_13', true}, + ['I don\'t want to say boy or girl. Don\'t ask.'] = {'/sc 6_14', true}, + [1] = '/sc 6' + }, + ['Game'] = { + ['Let\'s build'] = {'/sc 7_0', true}, + ['Let\'s battle'] = {'/sc 7_1', true}, + ['Nice one!'] = {'/sc 7_2', true}, + ['So far so good'] = {'/sc 7_3', true}, + ['Lucky shot!'] = {'/sc 7_4', true}, + ['Oh man!'] = {'/sc 7_5', true}, + ['I challenge you to a fight!'] = {'/sc 7_6', true}, + ['Help me with this'] = {'/sc 7_7', true}, + ['Let\'s go to your game'] = {'/sc 7_8', true}, + ['Can you show me how do to that?'] = {'/sc 7_9', true}, + ['Backflip!'] = {'/sc 7_10', true}, + ['Frontflip!'] = {'/sc 7_11', true}, + ['Dance!'] = {'/sc 7_12', true}, + ['I\'m on your side!'] = {'/sc 7_13', true}, + ['Game Commands'] = {'/sc 7_14', true, ['regen'] = true, ['reset'] = true, ['go'] = true, ['fix'] = true, ['respawn'] = true}, + [1] = '/sc 7' + }; + ['Silly'] = { + ['Muahahahaha!'] = true, + ['all your base are belong to me!'] = true, + ['GET OFF MAH LAWN'] = true, + ['TEH EPIK DUCK IS COMING!!!'] = true, + ['ROFL'] = true, + ['1337'] = {true, ['i r teh pwnz0r!'] = true, ['w00t!'] = true, ['z0mg h4x!'] = true, ['ub3rR0xXorzage!'] = true} + }, + ['Yes'] = { + ['Absolutely!'] = true, + ['Rock on!'] = true, + ['Totally!'] = true, + ['Juice!'] = true, + ['Yay!'] = true, + ['Yesh'] = true + }, + ['No'] = { + ['Ummm. No.'] = true, + ['...'] = true, + ['Stop!'] = true, + ['Go away!'] = true, + ['Don\'t do that'] = true, + ['Stop breaking the rules'] = true, + ['I don\'t want to'] = true + }, + ['Ok'] = { + ['Well... ok'] = true, + ['Sure'] = true + }, + ['Uncertain'] = { + ['Maybe'] = true, + ['I don\'t know'] = true, + ['idk'] = true, + ['I can\'t decide'] = true, + ['Hmm...'] = true + }, + [':-)'] = { + [':-('] = true, + [':D'] = true, + [':-O'] = true, + ['lol'] = true, + ['=D'] = true, + ['D='] = true, + ['XD'] = true, + [';D'] = true, + [';)'] = true, + ['O_O'] = true, + ['=)'] = true, + ['@_@'] = true, + ['>_<'] = true, + ['T_T'] = true, + ['^_^'] = true, + ['<(0_0<) <(0_0)> (>0_0)> KIRBY DANCE'] = true, + [')\';'] = true, + [':3'] = true + }, + ['Ratings'] = { + ['Rate it!'] = true, + ['I give it a 1 out of 10'] = true, + ['I give it a 2 out of 10'] = true, + ['I give it a 3 out of 10'] = true, + ['I give it a 4 out of 10'] = true, + ['I give it a 5 out of 10'] = true, + ['I give it a 6 out of 10'] = true, + ['I give it a 7 out of 10'] = true, + ['I give it a 8 out of 10'] = true, + ['I give it a 9 out of 10'] = true, + ['I give it a 10 out of 10!'] = true, + } + }, + CreateEnum('SafeChat'){'Level1', 'Level2', 'Level3'}, + SafeChatTree = {} + } +--------------------------------------------------- + + + +-- Check if we are running on a touch device +function Chat:IsTouchDevice() + local touchEnabled = false + pcall(function() touchEnabled = Game:GetService('UserInputService').TouchEnabled end) + return touchEnabled +end + +-- Scrolling +function Chat:ScrollQueue(value) + for i = 1, #self.MessageQueue do + if self.MessageQueue[i] then + for _, label in pairs(self.MessageQueue[i]) do + local next = self.MessageQueue[i].Next + local previous = self.MessageQueue[i].Previous + if label and label:IsA('TextLabel') or label:IsA('TextButton') then + if value > 0 and previous and previous['Message'] then + label.Position = previous['Message'].Position + elseif value < 1 and next['Message'] then + label.Position = previous['Message'].Position + end + end + end + end + end +end + + + +function Chat:FocusOnChatBar() + if self.ClickToChatButton then + self.ClickToChatButton.Visible = false + end + + self.GotFocus = true + if self.Frame['Background'] then + self.Frame.Background.Visible = false + end + self.ChatBar:CaptureFocus() +end -- For touch devices we create a button instead -function Chat:CreateTouchButton() +function Chat:CreateTouchButton() self.ChatTouchFrame = Gui.Create'Frame' { Name = 'ChatTouchFrame'; @@ -139,7 +485,7 @@ function Chat:CreateTouchButton() Size = UDim2.new(1, 0, 1, 0); Position = UDim2.new(0, 0, 0, 0); BackgroundTransparency = 1.0; - Image = 'http://www.morblox.us/asset/?id=97078724' + Image = 'http://www.roblox.com/asset/?id=97078724' }; } self.TapToChatLabel = self.ChatTouchFrame.ChatLabel @@ -149,7 +495,7 @@ function Chat:CreateTouchButton() { Name = 'ChatBar'; Size = UDim2.new(1, 0, 0.2, 0); - Position = UDim2.new(0, 0, 0.8, 800); + Position = UDim2.new(0, 0, 0.8, 0); Text = ""; ZIndex = 1.0; BackgroundTransparency = 1.0; @@ -162,7 +508,7 @@ function Chat:CreateTouchButton() self.TapToChatLabel.MouseButton1Click:connect(function() self.TapToChatLabel.Visible = false --self.ChatBar.Visible = true - --self.Frame.Background.Visible = true + self.Frame.Background.Visible = true self.ChatBar:CaptureFocus() self.GotFocus = true if self.TouchLabelBackground then @@ -174,7 +520,7 @@ end -- Non touch devices, create the bottom chat bar function Chat:CreateChatBar() -- okay now we do - local status, result = pcall(function() return GuiService.UseLuaChat end) + local status, result = pcall(function() return GuiService.UseLuaChat end) if status and result then self.ClickToChatButton = Gui.Create'TextButton' { @@ -208,11 +554,7 @@ function Chat:CreateChatBar() }; -- Engine has code to offset the entire world, so if we do it by -20 pixels nothing gets in our chat's way - --GuiService:SetGlobalSizeOffsetPixel(0, -20) - local success, error = pcall(function() GuiService:SetGlobalGuiInset(0, 0, 0, 20) end) - if not success then - GuiService:SetGlobalSizeOffsetPixel(0, -20) - end + GuiService:SetGlobalSizeOffsetPixel(0, -20) -- CHatHotKey is '/' GuiService:AddSpecialKey(Enum.SpecialKey.ChatHotkey) GuiService.SpecialKeyPressed:connect(function(key) @@ -227,6 +569,50 @@ function Chat:CreateChatBar() end end +-- For scrolling, to see if we hit the bounds so that we can stop it from scrolling anymore +function Chat:CheckIfInBounds(value) + if #Chat.MessageQueue < 3 then + return true + end + + if value > 0 and Chat.MessageQueue[1] and Chat.MessageQueue[1]['Player'] and Chat.MessageQueue[1]['Player'].Position.Y.Scale == 0 then + return true + elseif value < 0 and Chat.MessageQueue[1] and Chat.MessageQueue[1]['Player'] and Chat.MessageQueue[1]['Player'].Position.Y.Scale < 0 then + return true + else + return false + end + return false +end + +-- This is to precompute all playerName space strings +-- This is used to offset the message by exactly this + 2 spacestrings +function Chat:ComputeSpaceString(pLabel) + local tLabel = Gui.Create'TextButton' + { + Size = UDim2.new(0, pLabel.AbsoluteSize.X, 0, pLabel.AbsoluteSize.Y); + FontSize = self.Configuration.FontSize; + Parent = self.RenderFrame; + BackgroundTransparency = 1.0; + Text = nString; + }; + local nString = " " + while tLabel.TextBounds.X < pLabel.TextBounds.X do + nString = nString .. " " + tLabel.Text = nString + end + self.CachedSpaceStrings_List[pLabel.Text] = nString + return nString +end + + + +function Chat:ScreenSizeChanged() + while self.Frame.AbsoluteSize.Y > 120 do + self.Frame.Size = self.Frame.Size - UDim2.new(0, 0, 0.005, 0) + end +end + -- Create the initial Chat stuff -- Done only once function Chat:CreateGui() @@ -234,19 +620,17 @@ function Chat:CreateGui() self.Frame = Gui.Create'Frame' { Name = 'ChatFrame'; - --Size = self.Configuration.Size; - Size = UDim2.new(0, 500, 0, 120); + Size = self.Configuration.Size; Position = UDim2.new(0, 0, 0, 5); BackgroundTransparency = 1.0; --ClipsDescendants = true; ZIndex = 0.0; Parent = self.Gui; - Active = false; Gui.Create'ImageLabel' { Name = 'Background'; - Image = 'http://www.morblox.us/asset/?id=97120937'; --96551212'; + Image = 'http://www.roblox.com/asset/?id=97120937'; --96551212'; Size = UDim2.new(1.3, 0, 1.64, 0); Position = UDim2.new(0, 0, 0, 0); BackgroundTransparency = 1.0; @@ -271,19 +655,12 @@ function Chat:CreateGui() Size = UDim2.new(1.02, 0, 1.01, 0); Position = UDim2.new(0, 0, 0, 0); BackgroundTransparency = 1.0; - --ClipsDescendants = true; - ZIndex = 0.0; - Active = false; + ClipsDescendants = true; + ZIndex = 0.0; }; - }; - - Spawn(function() - wait(0.5) - if IsPhone() then - self.Frame.Size = UDim2.new(0, 280, 0, 120) - end - end) + }; + self.RenderFrame = self.Frame.ChatRenderFrame if Chat:IsTouchDevice() then @@ -296,12 +673,11 @@ function Chat:CreateGui() Chat:ScreenSizeChanged() end end) - end - - if Player.ChatMode == Enum.ChatMode.TextAndMenu then - if Chat:IsTouchDevice() then - Chat:CreateTouchButton() + end + if Player.ChatMode == Enum.ChatMode.TextAndMenu then + if Chat:IsTouchDevice() then + Chat:CreateTouchButton() else Chat:CreateChatBar() --Chat:CreateSafeChatGui() @@ -319,15 +695,11 @@ function Chat:CreateGui() end end if enterPressed and self.ChatBar.Text ~= "" then - - local cText = self.ChatBar.Text - if string.sub(self.ChatBar.Text, 1, 1) == '%' then - cText = '(TEAM) ' .. string.sub(cText, 2, #cText) - pcall(function() PlayersService:TeamChat(cText) end) - else - pcall(function() PlayersService:Chat(cText) end) + if PlayersService.ClassicChat then + pcall(function() PlayersService:Chat(self.ChatBar.Text) end) + elseif PlayersService.BubbleChat then + -- do nothing end - if self.ClickToChatButton then self.ClickToChatButton.Visible = true end @@ -344,6 +716,112 @@ function Chat:CreateGui() end end +function Chat:FindButtonTree(scButton, rootList) + local list = {} + rootList = rootList or self.SafeChatTree + for button, _ in pairs(rootList) do + if button == scButton then + list = rootList[button] + elseif type(rootList[button]) == 'table' then + list = Chat:FindButtonTree(scButton, rootList[button]) + end + end + return list +end + +function Chat:ToggleSafeChatMenu(scButton) + local list = Chat:FindButtonTree(scButton, self.SafeChatTree) + if list then + for button, _ in pairs(list) do + if button:IsA('TextButton') or button:IsA('ImageButton') then + button.Visible = not button.Visible + end + end + return true + end + return false +end + +function Chat:CreateSafeChatOptions(list, rootButton) + local text_List = {} + level = level or 0 + local count = 0 + text_List[rootButton] = {} + text_List[rootButton][1] = list[1] + rootButton = rootButton or self.SafeChatButton + for msg, _ in pairs(list) do + if type(msg) == 'string' then + local chatText = Gui.Create'TextButton' + { + Name = msg; + Text = msg; + Size = UDim2.new(0, 100, 0, 20); + TextXAlignment = Enum.TextXAlignment.Center; + TextColor3 = Color3.new(0.2, 0.1, 0.1); + BackgroundTransparency = 0.5; + BackgroundColor3 = Color3.new(1, 1, 1); + Parent = self.SafeChatFrame; + Visible = false; + Position = UDim2.new(0, rootButton.Position.X.Scale + 105, 0, rootButton.Position.Y.Scale - ((count - 3) * 100)); + }; + + count = count + 1 + + if type(list[msg]) == 'table' then + text_List[rootButton][chatText] = Chat:CreateSafeChatOptions(list[msg], chatText) + else + --table.insert(text_List[chatText], true) + end + chatText.MouseEnter:connect(function() + Chat:ToggleSafeChatMenu(chatText) + end) + + chatText.MouseLeave:connect(function() + Chat:ToggleSafeChatMenu(chatText) + end) + + chatText.MouseButton1Click:connect(function() + local lList = Chat:FindButtonTree(chatText) + if lList then + for i, v in pairs(lList) do + end + else + end + pcall(function() PlayersService:Chat(lList[1]) end) + end) + end + end + return text_List +end + +function Chat:CreateSafeChatGui() + self.SafeChatFrame = Gui.Create'Frame' + { + Name = 'SafeChatFrame'; + Size = UDim2.new(1, 0, 1, 0); + Parent = self.Gui; + BackgroundTransparency = 1.0; + + Gui.Create'ImageButton' + { + Name = 'SafeChatButton'; + Size = UDim2.new(0, 44, 0, 31); + Position = UDim2.new(0, 1, 0.35, 0); + BackgroundTransparency = 1.0; + Image = 'http://www.roblox.com/asset/?id=97080365'; + }; + } + + self.SafeChatButton = self.SafeChatFrame.SafeChatButton + -- safe chat button is the root of this tree + self.SafeChatTree[self.SafeChatButton] = Chat:CreateSafeChatOptions(self.SafeChat_List, self.SafeChatButton) + + self.SafeChatButton.MouseButton1Click:connect(function() + Chat:ToggleSafeChatMenu(self.SafeChatButton) + end) + +end + -- Scrolling function -- Applies a speed(velocity) to have nice scrolling effect function Input:OnMouseScroll() @@ -361,7 +839,7 @@ function Input:OnMouseScroll() wait(0.25) end end - wait(0.03) + wait() end end) if Chat:CheckIfInBounds(Input.Speed) then @@ -403,51 +881,9 @@ function Chat:FindMessageInSafeChat(message, list) return foundMessage end --- Just a wrapper around our PlayerChatted event -function Chat:PlayerChatted(...) - local args = {...} - local argCount = select('#', ...) - local player - local message - -- This doesn't look very good, but what else to do? - if args[2] then - player = args[2] - end - if args[3] then - message = args[3] - if string.sub(message, 1, 1) == '%' then - message = '(TEAM) ' .. string.sub(message, 2, #message) - end - end - if PlayersService.ClassicChat then - if Player.ChatMode == Enum.ChatMode.TextAndMenu then - Chat:UpdateChat(player, message) - elseif Player.ChatMode == Enum.ChatMode.Menu and string.sub(message, 3) == '/sc' then - Chat:UpdateChat(player, message) - else - if Chat:FindMessageInSafeChat(message, self.SafeChat_List) then - Chat:UpdateChat(player, message) - end - end - end -end --- After Chat.Configuration.Lifetime seconds of existence, the labels become invisible --- Runs only every 5 seconds and has to loop through 50 values --- Shouldn't be too expensive -function Chat:CullThread() - while true do - if #self.MessageQueue > 0 then - for _, field in pairs(self.MessageQueue) do - if field['SpawnTime'] and field['Player'] and field['Message'] and tick() - field['SpawnTime'] > self.Configuration.LifeTime then - field['Player'].Visible = false - field['Message'].Visible = false - end - end - end - wait(5.0) - end -end + + -- RobloxLock everything so users can't delete them(?) function Chat:LockAllFields(gui) @@ -462,7 +898,7 @@ end -- Constructor -- This function initializes everything -function Chat:Initialize() +function Chat:Initialize() Chat:CreateGui() self.EventListener = PlayersService.PlayerChatted:connect(function(...) -- This event has 4 callback arguments @@ -471,15 +907,11 @@ function Chat:Initialize() end) - self.MessageThread = coroutine.create(function() end) - coroutine.resume(self.MessageThread) - -- Initialize input for us Input:Initialize() -- Eww, everytime a player is added, you have to redo the connection -- Seems this is not automatic - -- NOTE: PlayerAdded only fires on the server, hence ChildAdded is used here - PlayersService.ChildAdded:connect(function() + Game.Players.ChildAdded:connect(function() Chat.EventListener:disconnect() self.EventListener = PlayersService.PlayerChatted:connect(function(...) -- This event has 4 callback arguments @@ -505,6 +937,3 @@ Chat:Initialize() - - -