From 37f38926956ab37d57284af6ebb226bd9255778e Mon Sep 17 00:00:00 2001 From: Lewin Kelly Date: Thu, 11 Apr 2024 00:21:50 +0100 Subject: [PATCH] Further corescript formatting improvements --- defs.d.lua | 31 +- luau/107893730.luau | 1315 ------------------------------ luau/36868950.luau | 54 +- luau/37801172.luau | 4 +- luau/39250920.luau | 18 +- luau/45284430.luau | 46 +- luau/46295863.luau | 67 +- luau/48488235.luau | 12 +- luau/48488398.luau | 2 +- luau/48488451.luau | 4 +- luau/53878047.luau | 12 +- luau/53878057.luau | 4 +- luau/60595411.luau | 6 +- luau/73157242.luau | 1885 ++++++++++++++++++++++--------------------- luau/89449008.luau | 2 +- luau/89449093.luau | 4 +- luau/97188756.luau | 66 +- luau/join.luau | 27 - luau/studio.luau | 38 +- 19 files changed, 1117 insertions(+), 2480 deletions(-) delete mode 100644 luau/107893730.luau diff --git a/defs.d.lua b/defs.d.lua index 41e95a7..17573cc 100644 --- a/defs.d.lua +++ b/defs.d.lua @@ -968,11 +968,6 @@ declare class EnumFontSize_INTERNAL extends Enum Size24: EnumFontSize Size36: EnumFontSize Size48: EnumFontSize - Size28: EnumFontSize - Size32: EnumFontSize - Size42: EnumFontSize - Size60: EnumFontSize - Size96: EnumFontSize end declare class EnumFontStyle extends EnumItem end declare class EnumFontStyle_INTERNAL extends Enum @@ -2615,8 +2610,6 @@ declare class EnumPriorityMethod_INTERNAL extends Enum AccumulatedError: EnumPriorityMethod end - - type ENUM_LIST = { AccessModifierType: EnumAccessModifierType_INTERNAL, ActionType: EnumActionType_INTERNAL, @@ -3741,7 +3734,8 @@ declare class CoreGui extends BasePlayerGui SelectionImageObject: GuiObject UserGuiRenderingChanged: RBXScriptSignal Version: number - RobloxGui: any + RobloxGui: ScreenGui + MercuryGui: ScreenGui -- lmfaooo function SetUserGuiRendering(self, enabled: boolean, guiAdornee: Instance, faceId: EnumNormalId, horizontalCurvature: number?): nil function TakeScreenshot(self): nil function ToggleRecording(self): nil @@ -5022,6 +5016,8 @@ declare class TextLabel extends GuiLabel TextWrapped: boolean TextXAlignment: EnumTextXAlignment TextYAlignment: EnumTextYAlignment + + FontSize: EnumFontSize function SetTextFromInput(self, text: string): nil end @@ -5544,6 +5540,9 @@ declare class InsertService extends Instance function SetBaseSetsUrl(self, baseSetsUrl: string): nil function SetCollectionUrl(self, collectionUrl: string): nil function SetUserSetsUrl(self, userSetsUrl: string): nil + function SetTrustLevel(self, trustLevel: number): nil + function SetFreeModelUrl(self, freeModelUrl: string): nil + function SetFreeDecalUrl(self, freeDecalUrl: string): nil end declare class JointInstance extends Instance @@ -6205,6 +6204,7 @@ declare class Terrain extends BasePart function AutoWedgeCell(self, x: number, y: number, z: number): boolean function SetWaterCell(self, x: number, y: number, z: number, waterForce: EnumWaterForce, waterDirection: EnumWaterDirection): nil function SetCell(self, x: number, y: number, z: number, material: EnumCellMaterial, orientation: EnumCellOrientation): nil + function GetCell(self, x: number, y: number, z: number): any -- "tuple" bruh end declare class TriangleMeshPart extends BasePart @@ -6263,6 +6263,8 @@ declare class Model extends PVInstance function RemovePersistentPlayer(self, playerInstance: Player?): nil function ScaleTo(self, newScaleFactor: number): nil function TranslateBy(self, delta: Vector3): nil + + function GetModelCFrame(self): CFrame end declare class BackpackItem extends Model @@ -7033,20 +7035,13 @@ end declare class ScriptContext extends Instance Error: RBXScriptSignal - ErrorDetailed: RBXScriptSignal ScriptsDisabled: boolean - function AddCoreScriptLocal(self, name: string, parent: Instance): nil - function ClearScriptProfilingData(self): nil - function DeserializeScriptProfilerString(self, jsonString: string): { [any]: any } - function GetCoverageStats(self): { any } - function SaveScriptProfilingData(self, filename: string): nil function SetTimeout(self, seconds: number): nil - function StartScriptProfiling(self, frequency: number?): nil - function StopScriptProfiling(self): string -- player or instance - function AddCoreScript(self, id: number, instance: Instance, name: string): nil - function RegisterLibrary(self, name: string, id: string): nil + function AddCoreScript(self, assetId: number, parent: Instance, name: string): nil + function AddStarterScript(self, assetId: number): nil + function RegisterLibrary(self, libraryName: string, assetId: string): nil function LibraryRegistrationComplete(self): nil end diff --git a/luau/107893730.luau b/luau/107893730.luau deleted file mode 100644 index 1be481f..0000000 --- a/luau/107893730.luau +++ /dev/null @@ -1,1315 +0,0 @@ ---!strict --- CoreGui.MercuryGui.CoreScripts/PurchasePromptScript -print "[Mercury]: Loaded corescript 107893730" - --- this script creates the gui and sends the web requests for in game purchase prompts - -local ContentProvider = game:GetService "ContentProvider" -local GuiService = game:GetService "GuiService" -local HttpService = game:GetService "HttpService" -local InsertService = game:GetService "InsertService" -local MarketplaceService = game:GetService "MarketplaceService" -local RunService = game:GetService "RunService" - --- wait for important items to appear -while not MarketplaceService do - RunService.Heartbeat:wait() - MarketplaceService = game:GetService "MarketplaceService" -end -while not game:FindFirstChild "CoreGui" do - RunService.Heartbeat:wait() -end -while not game.CoreGui:FindFirstChild "MercuryGui" do - RunService.Heartbeat:wait() -end - --------------------------------- Global Variables ---------------------------------------- --- utility variables -local baseUrl = ContentProvider.BaseUrl - --- data variables -local currentProductInfo, currentAssetId, currentCurrencyType, currentCurrencyAmount, currentEquipOnPurchase, currentProductId, currentServerResponseTable -local checkingPlayerFunds = false -local openBCUpSellWindowConnection -local purchasingConsumable = false -local enableBrowserWindowClosedEvent = true - --- gui variables -local openBuyCurrencyWindowConnection -local currentlyPrompting = false -local purchaseDialog -local tweenTime = 0.3 -local showPosition = UDim2.new(0.5, -330, 0.5, -200) -local hidePosition = UDim2.new(0.5, -330, 1, 25) --- local isSmallScreen -local spinning = false -local spinnerIcons --- local smallScreenThreshold = 450 - --- user facing images -local function assetUrl(id: number) - return `http://banland.xyz/asset?id={id}` -end - -local errorImageUrl = assetUrl(42557901) -local buyImageUrl = assetUrl(104651457) -local buyImageDownUrl = assetUrl(104651515) -local buyImageDisabledUrl = assetUrl(104651532) -local cancelButtonImageUrl = assetUrl(104651592) -local cancelButtonDownUrl = assetUrl(104651639) -local okButtonUrl = assetUrl(104651665) -local okButtonPressedrl = assetUrl(104651707) -local freeButtonImageUrl = assetUrl(104651733) -local freeButtonImageDownUrl = assetUrl(104651761) -local tixIcon = assetUrl(102481431) -local robuxIcon = assetUrl(102481419) - --- user facing string -local buyHeaderText = "Buy" -local takeHeaderText = "Take" -local buyFailedHeaderText = "An Error Occurred" - -local errorPurchasesDisabledText = "in-game purchases are disabled" -local errorPurchasesUnknownText = "Mercury is performing maintenance" - -local purchaseSucceededText = "Your purchase of itemName succeeded!" -local purchaseFailedText = - "Your purchase of itemName failed because errorReason. Your account has not been charged. Please try again soon." -local productPurchaseText = - "Would you like to buy 'itemName' for currencyType currencyAmount?" -local freeItemPurchaseText = - "Would you like to take the assetType 'itemName' for FREE?" -local freeItemBalanceText = - "Your balance of Robux or Tix will not be affected by this transaction." - --------------------------------- End Global Variables ---------------------------------------- - ------------------------------ Util Functions --------------------------------------------- - -local function getSecureApiBaseUrl() - local secureApiUrl = baseUrl - secureApiUrl = string.gsub(secureApiUrl, "http", "https") - secureApiUrl = string.gsub(secureApiUrl, "www", "api") - return secureApiUrl -end - -local function preloadAssets() - for _, url in ipairs { - errorImageUrl, - buyImageUrl, - buyImageDownUrl, - buyImageDisabledUrl, - cancelButtonImageUrl, - cancelButtonDownUrl, - okButtonUrl, - okButtonPressedrl, - freeButtonImageUrl, - freeButtonImageDownUrl, - tixIcon, - robuxIcon, - } do - ContentProvider:Preload(url) - end -end - ------------------------------ End Util Functions --------------------------------------------- - --------------------------------- Accept/Decline Functions -------------------------------------- - -local function removeCurrentPurchaseInfo() - currentAssetId = nil - currentCurrencyType = nil - currentCurrencyAmount = nil - currentEquipOnPurchase = nil - currentProductId = nil - currentProductInfo = nil - currentServerResponseTable = nil - - checkingPlayerFunds = false -end - -local function hidePurchasing() - purchaseDialog.PurchasingFrame.Visible = false - spinning = false -end - -local function closePurchasePrompt() - purchaseDialog:TweenPosition( - hidePosition, - Enum.EasingDirection.Out, - Enum.EasingStyle.Quad, - tweenTime, - true, - function() - game.GuiService:RemoveCenterDialog(purchaseDialog) - hidePurchasing() - purchaseDialog.Visible = false - currentlyPrompting = false - end - ) -end - -local function signalPromptEnded(isSuccess) - closePurchasePrompt() - if purchasingConsumable then - MarketplaceService:SignalPromptProductPurchaseFinished( - game.Players.LocalPlayer.userId, - currentProductId, - isSuccess - ) - else - MarketplaceService:SignalPromptPurchaseFinished( - game.Players.LocalPlayer, - currentAssetId, - isSuccess - ) - end - removeCurrentPurchaseInfo() -end - --- convenience method to say exactly what buttons should be visible (all others are not!) -local function setButtonsVisible(...) - local args = { ... } - local argCount = select("#", ...) - - local bodyFrameChildren = purchaseDialog.BodyFrame:GetChildren() - for i = 1, #bodyFrameChildren do - if bodyFrameChildren[i]:IsA "GuiButton" then - bodyFrameChildren[i].Visible = false - for j = 1, argCount do - if bodyFrameChildren[i] == args[j] then - bodyFrameChildren[i].Visible = true - break - end - end - end - end -end - -local function userPurchaseActionsEnded(isSuccess: boolean) - checkingPlayerFunds = false - - if isSuccess then -- show the user we bought the item successfully, when they close this dialog we will call signalPromptEnded - local newPurchasedSucceededText = string.gsub( - purchaseSucceededText, - "itemName", - tostring(currentProductInfo.Name) - ) - purchaseDialog.BodyFrame.ItemPreview.ItemDescription.Text = - newPurchasedSucceededText - setButtonsVisible(purchaseDialog.BodyFrame.OkPurchasedButton) - hidePurchasing() - else -- otherwise we didn't purchase, no need to show anything, just signal and close dialog - signalPromptEnded(isSuccess) - end -end - --- enums have no implicit conversion to numbers in lua, has to have a function to do this -local function currencyEnumToInt(currencyEnum: EnumItem) - if currencyEnum == Enum.CurrencyType.Tix then - return 2 - end - return 1 -end - --- oi, this is ugly -local function assetTypeToString(assetType: number) - if assetType == 1 then - return "Image" - elseif assetType == 2 then - return "T-Shirt" - elseif assetType == 3 then - return "Audio" - elseif assetType == 4 then - return "Mesh" - elseif assetType == 5 then - return "Lua" - elseif assetType == 6 then - return "HTML" - elseif assetType == 7 then - return "Text" - elseif assetType == 8 then - return "Hat" - elseif assetType == 9 then - return "Place" - elseif assetType == 10 then - return "Model" - elseif assetType == 11 then - return "Shirt" - elseif assetType == 12 then - return "Pants" - elseif assetType == 13 then - return "Decal" - elseif assetType == 16 then - return "Avatar" - elseif assetType == 17 then - return "Head" - elseif assetType == 18 then - return "Face" - elseif assetType == 19 then - return "Gear" - elseif assetType == 21 then - return "Badge" - elseif assetType == 22 then - return "Group Emblem" - elseif assetType == 24 then - return "Animation" - elseif assetType == 25 then - return "Arms" - elseif assetType == 26 then - return "Legs" - elseif assetType == 27 then - return "Torso" - elseif assetType == 28 then - return "Right Arm" - elseif assetType == 29 then - return "Left Arm" - elseif assetType == 30 then - return "Left Leg" - elseif assetType == 31 then - return "Right Leg" - elseif assetType == 32 then - return "Package" - elseif assetType == 33 then - return "YouTube Video" - elseif assetType == 34 then - return "Game Pass" - elseif assetType == 0 then - return "Product" - end - - return "" -end - -local function isFreeItem() - -- if both of these are true, then the item is free, just prompt user if they want to take one - return currentProductInfo - and currentProductInfo.IsForSale == true - and currentProductInfo.IsPublicDomain == true -end - -local function setHeaderText(text) - purchaseDialog.TitleLabel.Text = text - purchaseDialog.TitleBackdrop.Text = text -end - -local function currencyTypeToString(currencyType) - if currencyType == Enum.CurrencyType.Tix then - return "Tix" - end - return "R$" -end - --- make sure our gui displays the proper purchase data, and set the productid we will try and buy if use specifies a buy action -local function updatePurchasePromptData() - local newItemDescription = "" - - -- id to use when we request a purchase - if not currentProductId then - currentProductId = currentProductInfo.ProductId - end - - if isFreeItem() then - newItemDescription = string.gsub( - freeItemPurchaseText, - "itemName", - tostring(currentProductInfo.Name) - ) - newItemDescription = string.gsub( - newItemDescription, - "assetType", - tostring(assetTypeToString(currentProductInfo.AssetTypeId)) - ) - setHeaderText(takeHeaderText) - else -- otherwise item costs something, so different prompt - newItemDescription = string.gsub( - productPurchaseText, - "itemName", - tostring(currentProductInfo.Name) - ) - newItemDescription = string.gsub( - newItemDescription, - "currencyType", - tostring(currencyTypeToString(currentCurrencyType)) - ) - newItemDescription = string.gsub( - newItemDescription, - "currencyAmount", - tostring(currentCurrencyAmount) - ) - setHeaderText(buyHeaderText) - end - - purchaseDialog.BodyFrame.ItemPreview.ItemDescription.Text = - newItemDescription - - if purchasingConsumable then - purchaseDialog.BodyFrame.ItemPreview.Image = - `{baseUrl}thumbs/asset.ashx?assetid={currentProductInfo.IconImageAssetId}&x=100&y=100&format=png` - else - purchaseDialog.BodyFrame.ItemPreview.Image = - `{baseUrl}thumbs/asset.ashx?assetid={currentAssetId}&x=100&y=100&format=png` - end -end - --- more enum to int fun! -local function membershipTypeToNumber(membership: EnumItem) -- idk if there's a better type than EnumItem - if membership == Enum.MembershipType.None then - return 0 - elseif membership == Enum.MembershipType.BuildersClub then - return 1 - elseif membership == Enum.MembershipType.TurboBuildersClub then - return 2 - elseif membership == Enum.MembershipType.OutrageousBuildersClub then - return 3 - end - - return -1 -end - --- should open an external default browser window to this url -local function openBuyCurrencyWindow() - checkingPlayerFunds = true - GuiService:OpenBrowserWindow(`{baseUrl}Upgrades/Robux.aspx`) -end - --- set up the gui text at the bottom of the prompt (alerts user to how much money they will have left, or if they need to buy more to buy the item) -local function updateAfterBalanceText(playerBalance, notRightBc) - if isFreeItem() then - purchaseDialog.BodyFrame.AfterBalanceButton.Text = freeItemBalanceText - return true, false - end - - local keyWord - if currentCurrencyType == Enum.CurrencyType.Robux then - keyWord = "robux" - elseif currentCurrencyType == Enum.CurrencyType.Tix then - keyWord = "tickets" - end - - if not keyWord then - return false, false - end - - local playerBalanceNumber = tonumber(playerBalance[keyWord]) - if not playerBalanceNumber then - return false, false - end - - local afterBalanceNumber = playerBalanceNumber - currentCurrencyAmount - - -- check to see if we have enough of the desired currency to allow a purchase, if not we need to prompt user to buy robux - if not notRightBc then - if afterBalanceNumber < 0 and keyWord == "robux" then - if openBuyCurrencyWindowConnection == nil then - openBuyCurrencyWindowConnection = - purchaseDialog.BodyFrame.AfterBalanceButton.MouseButton1Click:connect( - openBuyCurrencyWindow - ) - end - purchaseDialog.BodyFrame.AfterBalanceButton.Text = - `You need R$ {-afterBalanceNumber} more to buy this, click here to purchase more.` - return true, true - elseif afterBalanceNumber < 0 and keyWord == "tickets" then - purchaseDialog.BodyFrame.AfterBalanceButton.Text = - `You need {-afterBalanceNumber} Tix more to buy this item.` - return true, true -- user can't buy more tickets, so we say fail the transaction (maybe instead we can prompt them to trade currency???) - end - end - - -- this ensures that we only have one connection to openBuyCurrencyWindow at a time (otherwise might open multiple browser windows) - if openBuyCurrencyWindowConnection then - openBuyCurrencyWindowConnection:disconnect() - openBuyCurrencyWindowConnection = nil - end - purchaseDialog.BodyFrame.AfterBalanceButton.Text = - `Your balance after this transaction will be {currencyTypeToString( - currentCurrencyType - )} {afterBalanceNumber}.` - return true, false -end - --- will get the player's balance of robux and tix, return in a table -local function getPlayerBalance() - local playerBalance - local ok, errorCode = ypcall(function() - playerBalance = - game:HttpGetAsync(`{getSecureApiBaseUrl()}currency/balance`) - end) - if not ok then - print("Get player balance failed because", errorCode) - return - elseif playerBalance == "" then - return - end - - return HttpService:JSONDecode(playerBalance) -end - --- figure out what currency to use based on the currency you can actually sell the item in and what the script specified -local function setCurrencyAmountAndType(priceInRobux, priceInTix) - if - currentCurrencyType == Enum.CurrencyType.Default - or currentCurrencyType == Enum.CurrencyType.Robux - then -- sell for default (user doesn't care) or robux - if priceInRobux ~= nil and priceInRobux ~= 0 then -- we can sell for robux - currentCurrencyAmount = priceInRobux - currentCurrencyType = Enum.CurrencyType.Robux - else -- have to use tix - currentCurrencyAmount = priceInTix - currentCurrencyType = Enum.CurrencyType.Tix - end - elseif currentCurrencyType == Enum.CurrencyType.Tix then -- we want to sell for tix - if priceInTix ~= nil and priceInTix ~= 0 then -- we can sell for tix - currentCurrencyAmount = priceInTix - currentCurrencyType = Enum.CurrencyType.Tix - else -- have to use robux - currentCurrencyAmount = priceInRobux - currentCurrencyType = Enum.CurrencyType.Robux - end - else - return false - end - - if currentCurrencyAmount == nil then - return false - end - - return true -end - --- This functions checks to make sure the purchase is even possible, if not it returns false and we don't prompt user (some situations require user feedback when we won't prompt) -local function canPurchaseItem() - -- first we see if player already owns the asset/get the productinfo - local playerOwnsAsset = false - local notRightBc = false - local descText - local ok = false - - if purchasingConsumable then - local currentProductInfoRaw - ok = ypcall(function() - currentProductInfoRaw = game:HttpGetAsync( - `{getSecureApiBaseUrl()}marketplace/productDetails?productid={currentProductId}` - ) - end) - if ok then - currentProductInfo = HttpService:JSONDecode(currentProductInfoRaw) - end - else - ok = ypcall(function() - currentProductInfo = - MarketplaceService:GetProductInfo(currentAssetId) - end) - end - - if currentProductInfo == nil or not ok then - return true, - nil, - nil, - true, - "In-game sales are temporarily disabled. Please try again later." - end - - if not purchasingConsumable then - if not currentAssetId then - print "current asset id is nil, this should always have a value" - return false - end - if currentAssetId <= 0 then - print "current asset id is negative, this should always be positive" - return false - end - - local success2, errorCode = ypcall(function() - playerOwnsAsset = game:HttpGetAsync( - `{getSecureApiBaseUrl()}ownership/hasAsset?userId={game.Players.LocalPlayer.userId}&assetId={currentAssetId}` - ) - end) - - if not success2 then - print("could not tell if player owns asset because", errorCode) - return false - end - - if playerOwnsAsset == true or playerOwnsAsset == "true" then - descText = "You already own this item." - return true, nil, nil, true, descText - end - end - - purchaseDialog.BodyFrame.AfterBalanceButton.Visible = true - - -- next we parse through product info and see if we can purchase - - if type(currentProductInfo) ~= "table" then - currentProductInfo = HttpService:JSONDecode(currentProductInfo) - end - - if not currentProductInfo then - descText = "Could not get product info. Please try again later." - return true, nil, nil, true, descText - end - - if - currentProductInfo.IsForSale == false - and currentProductInfo.IsPublicDomain == false - then - descText = "This item is no longer for sale." - return true, nil, nil, true, descText - end - - -- now we start talking money, making sure we are going to be able to purchase this - if - not setCurrencyAmountAndType( - tonumber(currentProductInfo.PriceInRobux), - tonumber(currentProductInfo.PriceInTickets) - ) - then - descText = - "We could retrieve the price of the item correctly. Please try again later." - return true, nil, nil, true, descText - end - - local playerBalance = getPlayerBalance() - if not playerBalance then - descText = "Could not retrieve your balance. Please try again later." - return true, nil, nil, true, descText - end - - if - tonumber(currentProductInfo.MinimumMembershipLevel) - > membershipTypeToNumber(game.Players.LocalPlayer.MembershipType) - then - notRightBc = true - end - - local updatedBalance, insufficientFunds = - updateAfterBalanceText(playerBalance, notRightBc) - - if notRightBc then - purchaseDialog.BodyFrame.AfterBalanceButton.Active = true - return true, insufficientFunds, notRightBc, false - end - - if currentProductInfo.ContentRatingTypeId == 1 then - if game.Players.LocalPlayer:GetUnder13() then - descText = - "Your account is under 13 so purchase of this item is not allowed." - return true, nil, nil, true, descText - end - end - - if - ( - currentProductInfo.IsLimited == true - or currentProductInfo.IsLimitedUnique == true - ) - and ( - currentProductInfo.Remaining == "" - or currentProductInfo.Remaining == 0 - or currentProductInfo.Remaining == nil - ) - then - descText = - "All copies of this item have been sold out! Try buying from other users on the website." - return true, nil, nil, true, descText - end - - if not updatedBalance then - descText = - "Could not update your balance. Please check back after some time." - return true, nil, nil, true, descText - end - - -- we use insufficient funds to display a prompt to buy more robux - purchaseDialog.BodyFrame.AfterBalanceButton.Active = true - return true, insufficientFunds -end - -local function doPlayerFundsCheck(checkIndefinitely) - if checkingPlayerFunds then - local canPurchase, insufficientFunds = canPurchaseItem() -- check again to see if we can buy item - if canPurchase and insufficientFunds then -- wait a bit and try a few more times - local retries = 1000 - while - (retries > 0 or checkIndefinitely) - and insufficientFunds - and checkingPlayerFunds - and canPurchase - do - wait(0.1) - canPurchase, insufficientFunds = canPurchaseItem() - retries -= 1 - end - end - if canPurchase and not insufficientFunds then - -- we can buy item! set our buttons up and we will exit this loop - setButtonsVisible( - purchaseDialog.BodyFrame.BuyButton, - purchaseDialog.BodyFrame.CancelButton, - purchaseDialog.BodyFrame.AfterBalanceButton - ) - end - end -end - -local function openBCUpSellWindow() - GuiService:OpenBrowserWindow( - `{baseUrl}Upgrades/BuildersClubMemberships.aspx` - ) -end - --- user pressed the cancel button, just remove all purchasing prompts - -local function showPurchasePrompt() - local canPurchase, insufficientFunds, notRightBC, override, descText = - canPurchaseItem() - - if canPurchase then - updatePurchasePromptData() - - if override and descText then - purchaseDialog.BodyFrame.ItemPreview.ItemDescription.Text = descText - purchaseDialog.BodyFrame.AfterBalanceButton.Visible = false - end - game.GuiService:AddCenterDialog( - purchaseDialog, - Enum.CenterDialogType.ModalDialog, - --ShowFunction - function() - -- set the state for our buttons - purchaseDialog.Visible = true - if isFreeItem() then - setButtonsVisible( - purchaseDialog.BodyFrame.FreeButton, - purchaseDialog.BodyFrame.CancelButton, - purchaseDialog.BodyFrame.AfterBalanceButton - ) - elseif notRightBC then - purchaseDialog.BodyFrame.AfterBalanceButton.Text = - "You require an upgrade to your Builders Club membership to purchase this item. Click here to upgrade." - if not openBCUpSellWindowConnection then - openBCUpSellWindowConnection = purchaseDialog.BodyFrame.AfterBalanceButton.MouseButton1Click:connect( - function() - if - purchaseDialog.BodyFrame.AfterBalanceButton.Text - == "You require an upgrade to your Builders Club membership to purchase this item. Click here to upgrade." - then - openBCUpSellWindow() - end - end - ) - end - setButtonsVisible( - purchaseDialog.BodyFrame.BuyDisabledButton, - purchaseDialog.BodyFrame.CancelButton, - purchaseDialog.BodyFrame.AfterBalanceButton - ) - elseif insufficientFunds then - setButtonsVisible( - purchaseDialog.BodyFrame.BuyDisabledButton, - purchaseDialog.BodyFrame.CancelButton, - purchaseDialog.BodyFrame.AfterBalanceButton - ) - elseif override then - setButtonsVisible( - purchaseDialog.BodyFrame.BuyDisabledButton, - purchaseDialog.BodyFrame.CancelButton - ) -- , purchaseDialog.BodyFrame.AfterBalanceButton) - else - setButtonsVisible( - purchaseDialog.BodyFrame.BuyButton, - purchaseDialog.BodyFrame.CancelButton - ) -- , purchaseDialog.BodyFrame.AfterBalanceButton) - end - - purchaseDialog:TweenPosition( - showPosition, - Enum.EasingDirection.Out, - Enum.EasingStyle.Quad, - tweenTime, - true - ) - - if - canPurchase - and insufficientFunds - and not enableBrowserWindowClosedEvent - then - checkingPlayerFunds = true - doPlayerFundsCheck(true) - end - end, - --HideFunction - function() - purchaseDialog.Visible = false - end - ) - else -- we failed in prompting a purchase, do a decline - userPurchaseActionsEnded(false) - end -end - --- given an asset id, this function will grab that asset from the website, and return the first "Tool" object found inside it -local function getToolAssetID(assetID) - local newTool = InsertService:LoadAsset(assetID) - if not newTool then - return nil - end - - if newTool:IsA "Tool" then - return newTool - end - - local toolChildren = newTool:GetChildren() - for i = 1, #toolChildren do - if toolChildren[i]:IsA "Tool" then - return toolChildren[i] - end - end - return nil -end - --- the user tried to purchase by clicking the purchase button, but something went wrong. --- let them know their account was not charged, and that they do not own the item yet. -local function purchaseFailed(inGamePurchasesDisabled) - local name = "Item" - if currentProductInfo then - name = currentProductInfo.Name - end - - local newPurchasedFailedText = - string.gsub(purchaseFailedText, "itemName", tostring(name)) - if inGamePurchasesDisabled then - newPurchasedFailedText = string.gsub( - newPurchasedFailedText, - "errorReason", - tostring(errorPurchasesDisabledText) - ) - else - newPurchasedFailedText = string.gsub( - newPurchasedFailedText, - "errorReason", - tostring(errorPurchasesUnknownText) - ) - end - - purchaseDialog.BodyFrame.ItemPreview.ItemDescription.Text = - newPurchasedFailedText - purchaseDialog.BodyFrame.ItemPreview.Image = errorImageUrl - - setButtonsVisible(purchaseDialog.BodyFrame.OkButton) - - setHeaderText(buyFailedHeaderText) - - hidePurchasing() -end - -local function startSpinner() - spinning = true - Spawn(function() - local spinPos = 0 - while spinning do - local pos = 0 - - while pos < 8 do - if pos == spinPos or pos == ((spinPos + 1) % 8) then - spinnerIcons[pos + 1].Image = assetUrl(45880668) - else - spinnerIcons[pos + 1].Image = assetUrl(45880710) - end - - pos += 1 - end - spinPos = (spinPos + 1) % 8 - wait(1 / 15) - end - end) -end - --- user has specified they want to buy an item, now try to attempt to buy it for them -local function acceptPurchase() - -- shows a purchasing ui (shows spinner) - startSpinner() - purchaseDialog.PurchasingFrame.Visible = true - - local startTime = tick() - - -- http call to do the purchase - local response = "none" - local url = `{getSecureApiBaseUrl()}marketplace/` - - local currencyData = `¤cyTypeId={currencyEnumToInt( - currentCurrencyType - )}¤cyTypeId={currencyEnumToInt(currentCurrencyType)}` - - -- consumables need to use a different url - if purchasingConsumable then - url ..= `submitpurchase?productId={currentProductId}{currencyData}&expectedUnitPrice={currentCurrencyAmount}&placeId={game.PlaceId}` - else - url ..= `purchase?productId={currentProductId}{currencyData}&purchasePrice={currentCurrencyAmount}&locationType=Game&locationId={game.PlaceId}` - end - - local ok, reason = ypcall(function() - response = game:HttpPostAsync(url, "RobloxPurchaseRequest") - end) - - -- debug output for us (found in the logs from local) - print("acceptPurchase success from ypcall is ", ok, "reason is", reason) - - if tick() - startTime < 1 then - wait(1) -- allow the purchasing waiting dialog to at least be readable (otherwise it might flash, looks bad)... - end - - -- check to make sure purchase actually happened on the web end - if response == "none" or response == nil or response == "" then - print( - "did not get a proper response from web on purchase of", - currentAssetId, - currentProductId - ) - purchaseFailed(false) - return - end - - -- parse our response, decide how to react - response = HttpService:JSONDecode(response) - - if response then - if response.success == false and response.status ~= "AlreadyOwned" then - print( - "web return response of fail on purchase of", - currentAssetId, - currentProductId - ) - purchaseFailed(response.status == "EconomyDisabled") - return - end - else - print( - "web return response of non parsable JSON on purchase of", - currentAssetId - ) - purchaseFailed(false) - return - end - - -- check to see if this item was bought, and if we want to equip it (also need to make sure the asset type was gear) - if - currentEquipOnPurchase - and ok - and currentAssetId - and tonumber(currentProductInfo.AssetTypeId) == 19 - then - local tool = getToolAssetID(tonumber(currentAssetId)) - if tool then - tool.Parent = game.Players.LocalPlayer.Backpack - end - end - - if purchasingConsumable then - if not response.receipt then - print( - "tried to buy productId, but no receipt returned. productId was", - currentProductId - ) - purchaseFailed(false) - return - end - MarketplaceService:SignalClientPurchaseSuccess( - tostring(response.receipt), - game.Players.LocalPlayer.userId, - currentProductId - ) - else - userPurchaseActionsEnded(ok) - end -end - --------------------------------- End Accept/Decline Functions -------------------------------------- - ----------------------------------------------- Gui Functions ---------------------------------------------- - --- used for the "Purchasing..." frame -local function createSpinner(size, position, parent) - local spinnerFrame = Instance.new "Frame" - spinnerFrame.Name = "Spinner" - spinnerFrame.Size = size - spinnerFrame.Position = position - spinnerFrame.BackgroundTransparency = 1 - spinnerFrame.ZIndex = 10 - spinnerFrame.Parent = parent - - spinnerIcons = {} - local spinnerNum = 1 - while spinnerNum <= 8 do - local spinnerImage = Instance.new "ImageLabel" - spinnerImage.Name = `Spinner{spinnerNum}` - spinnerImage.Size = UDim2.new(0, 16, 0, 16) - spinnerImage.Position = UDim2.new( - 0.5 + 0.3 * math.cos(math.rad(45 * spinnerNum)), - -8, - 0.5 + 0.3 * math.sin(math.rad(45 * spinnerNum)), - -8 - ) - spinnerImage.BackgroundTransparency = 1 - spinnerImage.ZIndex = 10 - spinnerImage.Image = assetUrl(45880710) - spinnerImage.Parent = spinnerFrame - - spinnerIcons[spinnerNum] = spinnerImage - spinnerNum += 1 - end -end - -local function userPurchaseProductActionsEnded(userIsClosingDialog) - checkingPlayerFunds = false - - if userIsClosingDialog then - closePurchasePrompt() - if currentServerResponseTable then - local isPurchased = false - if - string.lower(tostring(currentServerResponseTable.isValid)) - == "true" - then - isPurchased = true - end - - MarketplaceService:SignalPromptProductPurchaseFinished( - tonumber(currentServerResponseTable.playerId), - tonumber(currentServerResponseTable.productId), - isPurchased - ) - else - print "Something went wrong, no currentServerResponseTable" - end - removeCurrentPurchaseInfo() - else - local newPurchasedSucceededText = string.gsub( - purchaseSucceededText, - "itemName", - tostring(currentProductInfo.Name) - ) - purchaseDialog.BodyFrame.ItemPreview.ItemDescription.Text = - newPurchasedSucceededText - setButtonsVisible(purchaseDialog.BodyFrame.OkPurchasedButton) - hidePurchasing() - end -end - -local function createImageButton(name) - local imageButton = Instance.new "ImageButton" - imageButton.Size = UDim2.new(0, 153, 0, 46) - imageButton.Name = name - return imageButton -end - -local function createTextObject(name, text, type, size) - local textLabel = Instance.new(type) - textLabel.Font = Enum.Font.ArialBold - textLabel.TextColor3 = Color3.new(217 / 255, 217 / 255, 217 / 255) - textLabel.TextWrapped = true - textLabel.Name = name - textLabel.Text = text - textLabel.BackgroundTransparency = 1 - textLabel.BorderSizePixel = 0 - textLabel.FontSize = size - - return textLabel -end - --- all the gui init. Would be nice if this didn't have to be a script -local function createPurchasePromptGui() - purchaseDialog = Instance.new "Frame" - purchaseDialog.Name = "PurchaseFrame" - purchaseDialog.Size = UDim2.new(0, 660, 0, 400) - purchaseDialog.Position = hidePosition - purchaseDialog.Visible = false - purchaseDialog.BackgroundColor3 = - Color3.new(141 / 255, 141 / 255, 141 / 255) - purchaseDialog.BorderColor3 = Color3.new(204 / 255, 204 / 255, 204 / 255) - purchaseDialog.Parent = game.CoreGui.MercuryGui - - local bodyFrame = Instance.new "Frame" - bodyFrame.Name = "BodyFrame" - bodyFrame.Size = UDim2.new(1, 0, 1, -60) - bodyFrame.Position = UDim2.new(0, 0, 0, 60) - bodyFrame.BackgroundColor3 = Color3.new(67 / 255, 67 / 255, 67 / 255) - bodyFrame.BorderSizePixel = 0 - bodyFrame.ZIndex = 8 - bodyFrame.Parent = purchaseDialog - - local titleLabel = createTextObject( - "TitleLabel", - "Buy Item", - "TextLabel", - Enum.FontSize.Size48 - ) - titleLabel.ZIndex = 8 - titleLabel.Size = UDim2.new(1, 0, 0, 60) - local titleBackdrop = titleLabel:Clone() - titleBackdrop.Name = "TitleBackdrop" - titleBackdrop.TextColor3 = Color3.new(32 / 255, 32 / 255, 32 / 255) - titleBackdrop.BackgroundTransparency = 0.0 - titleBackdrop.BackgroundColor3 = Color3.new(54 / 255, 96 / 255, 171 / 255) - titleBackdrop.Position = UDim2.new(0, 0, 0, -2) - titleBackdrop.ZIndex = 8 - titleBackdrop.Parent = purchaseDialog - titleLabel.Parent = purchaseDialog - - local distanceBetweenButtons = 90 - - local cancelButton = createImageButton "CancelButton" - cancelButton.Position = - UDim2.new(0.5, (distanceBetweenButtons / 2), 1, -120) - cancelButton.BackgroundTransparency = 1 - cancelButton.BorderSizePixel = 0 - cancelButton.Parent = bodyFrame - cancelButton.Modal = true - cancelButton.ZIndex = 8 - cancelButton.Image = cancelButtonImageUrl - cancelButton.MouseButton1Down:connect(function() - cancelButton.Image = cancelButtonDownUrl - end) - cancelButton.MouseButton1Up:connect(function() - cancelButton.Image = cancelButtonImageUrl - end) - cancelButton.MouseLeave:connect(function() - cancelButton.Image = cancelButtonImageUrl - end) - cancelButton.MouseButton1Click:connect(function() - -- user pressed the cancel button, just remove all purchasing prompts - userPurchaseActionsEnded(false) - end) - - local buyButton = createImageButton "BuyButton" - buyButton.Position = - UDim2.new(0.5, -153 - (distanceBetweenButtons / 2), 1, -120) - buyButton.BackgroundTransparency = 1 - buyButton.BorderSizePixel = 0 - buyButton.Image = buyImageUrl - buyButton.ZIndex = 8 - buyButton.MouseButton1Down:connect(function() - buyButton.Image = buyImageDownUrl - end) - buyButton.MouseButton1Up:connect(function() - buyButton.Image = buyImageUrl - end) - buyButton.MouseLeave:connect(function() - buyButton.Image = buyImageUrl - end) - buyButton.Parent = bodyFrame - - local buyDisabledButton = buyButton:Clone() - buyDisabledButton.Name = "BuyDisabledButton" - buyDisabledButton.AutoButtonColor = false - buyDisabledButton.Visible = false - buyDisabledButton.Active = false - buyDisabledButton.Image = buyImageDisabledUrl - buyDisabledButton.ZIndex = 8 - buyDisabledButton.Parent = bodyFrame - - local freeButton = buyButton:Clone() - freeButton.BackgroundTransparency = 1 - freeButton.Name = "FreeButton" - freeButton.Visible = false - freeButton.ZIndex = 8 - freeButton.Image = freeButtonImageUrl - freeButton.MouseButton1Down:connect(function() - freeButton.Image = freeButtonImageDownUrl - end) - freeButton.MouseButton1Up:connect(function() - freeButton.Image = freeButtonImageUrl - end) - freeButton.MouseLeave:connect(function() - freeButton.Image = freeButtonImageUrl - end) - freeButton.Parent = bodyFrame - - local okButton = buyButton:Clone() - okButton.Name = "OkButton" - okButton.BackgroundTransparency = 1 - okButton.Visible = false - okButton.Position = UDim2.new(0.5, -okButton.Size.X.Offset / 2, 1, -120) - okButton.Modal = true - okButton.Image = okButtonUrl - okButton.ZIndex = 8 - okButton.MouseButton1Down:connect(function() - okButton.Image = okButtonPressedrl - end) - okButton.MouseButton1Up:connect(function() - okButton.Image = okButtonUrl - end) - okButton.MouseLeave:connect(function() - okButton.Image = okButtonUrl - end) - okButton.Parent = bodyFrame - - local okPurchasedButton = okButton:Clone() - okPurchasedButton.ZIndex = 8 - okPurchasedButton.Name = "OkPurchasedButton" - okPurchasedButton.MouseButton1Down:connect(function() - okPurchasedButton.Image = okButtonPressedrl - end) - okPurchasedButton.MouseButton1Up:connect(function() - okPurchasedButton.Image = okButtonUrl - end) - okPurchasedButton.MouseLeave:connect(function() - okPurchasedButton.Image = okButtonUrl - end) - okPurchasedButton.Parent = bodyFrame - - okButton.MouseButton1Click:connect(function() - userPurchaseActionsEnded(false) - end) - okPurchasedButton.MouseButton1Click:connect(function() - if purchasingConsumable then - userPurchaseProductActionsEnded(true) - else - signalPromptEnded(true) - end - end) - buyButton.MouseButton1Click:connect(function() - acceptPurchase() - end) - freeButton.MouseButton1Click:connect(function() - acceptPurchase() - end) - - local itemPreview = Instance.new "ImageLabel" - itemPreview.Name = "ItemPreview" - itemPreview.BackgroundColor3 = Color3.new(32 / 255, 32 / 255, 32 / 255) - itemPreview.BorderColor3 = Color3.new(141 / 255, 141 / 255, 141 / 255) - itemPreview.Position = UDim2.new(0, 30, 0, 20) - itemPreview.Size = UDim2.new(0, 180, 0, 180) - itemPreview.ZIndex = 9 - itemPreview.Parent = bodyFrame - - local itemDescription = createTextObject( - "ItemDescription", - "Would you like to buy the 'itemName' for currencyType currencyAmount?", - "TextLabel", - Enum.FontSize.Size24 - ) - itemDescription.Position = UDim2.new(1, 20, 0, 0) - itemDescription.Size = UDim2.new(0, 410, 1, 0) - itemDescription.ZIndex = 8 - itemDescription.Parent = itemPreview - - local afterBalanceButton = createTextObject( - "AfterBalanceButton", - "Place holder text ip sum lorem dodo ashs", - "TextButton", - Enum.FontSize.Size24 - ) - afterBalanceButton.AutoButtonColor = false - afterBalanceButton.TextColor3 = Color3.new(222 / 255, 59 / 255, 30 / 255) - afterBalanceButton.Position = UDim2.new(0, 5, 1, -55) - afterBalanceButton.Size = UDim2.new(1, -10, 0, 50) - afterBalanceButton.ZIndex = 8 - afterBalanceButton.Parent = bodyFrame - - local purchasingFrame = Instance.new "Frame" - purchasingFrame.Name = "PurchasingFrame" - purchasingFrame.Size = UDim2.new(1, 0, 1, 0) - purchasingFrame.BackgroundColor3 = Color3.new(0, 0, 0) - purchasingFrame.BackgroundTransparency = 0.2 - purchasingFrame.BorderSizePixel = 0 - purchasingFrame.ZIndex = 9 - purchasingFrame.Visible = false - purchasingFrame.Active = true - purchasingFrame.Parent = purchaseDialog - - local purchasingLabel = createTextObject( - "PurchasingLabel", - "Purchasing...", - "TextLabel", - Enum.FontSize.Size48 - ) - purchasingLabel.Size = UDim2.new(1, 0, 1, 0) - purchasingLabel.ZIndex = 10 - purchasingLabel.Parent = purchasingFrame - - createSpinner( - UDim2.new(0, 50, 0, 50), - UDim2.new(0.5, -25, 0.5, 30), - purchasingLabel - ) -end - -local function doPurchasePrompt( - player: Player, - assetId, - equipIfPurchased, - currencyType, - productId -) - if not purchaseDialog then - createPurchasePromptGui() - end - - if player == game.Players.LocalPlayer then - if currentlyPrompting then - return - end - - currentlyPrompting = true - - currentAssetId = assetId - currentProductId = productId - currentCurrencyType = currencyType - currentEquipOnPurchase = equipIfPurchased - - purchasingConsumable = (currentProductId ~= nil) - - showPurchasePrompt() - end -end - -local function doProcessServerPurchaseResponse(serverResponseTable) - if not serverResponseTable then - print "Server response table was nil, cancelling purchase" - purchaseFailed(false) - return - end - - if - serverResponseTable.playerId - and tonumber(serverResponseTable.playerId) - == game.Players.LocalPlayer.userId - then - currentServerResponseTable = serverResponseTable - userPurchaseProductActionsEnded(false) - end -end - ----------------------------------------------- End Gui Functions ---------------------------------------------- - ----------------------------------------------- Script Event start/initialization ---------------------------------------------- -preloadAssets() - -MarketplaceService.PromptProductPurchaseRequested:connect( - function(player, productId, equipIfPurchased, currencyType) - doPurchasePrompt(player, nil, equipIfPurchased, currencyType, productId) - end -) - -MarketplaceService.PromptPurchaseRequested:connect( - function(player, assetId, equipIfPurchased, currencyType) - doPurchasePrompt(player, assetId, equipIfPurchased, currencyType, nil) - end -) - -MarketplaceService.ServerPurchaseVerification:connect( - function(serverResponseTable) - doProcessServerPurchaseResponse(serverResponseTable) - end -) - -if enableBrowserWindowClosedEvent then - GuiService.BrowserWindowClosed:connect(function() - doPlayerFundsCheck(false) - end) -end diff --git a/luau/36868950.luau b/luau/36868950.luau index 90ef392..2d1e0c0 100644 --- a/luau/36868950.luau +++ b/luau/36868950.luau @@ -1,5 +1,5 @@ --!strict --- CoreGui.MercuryGui.CoreScripts/ToolTip +-- CoreGui.RobloxGui.CoreScripts/ToolTip print "[Mercury]: Loaded corescript 36868950" local News = require "../Modules/New" @@ -31,31 +31,39 @@ local frameTip = New "TextLabel" { BackgroundColor3 = Color3.new(0, 0, 0), BackgroundTransparency = 1, TextTransparency = 1, - TextWrap = true, + TextWrapped = true, New "BoolValue" { Name = "inside", Value = false, }, } -local function setUpListeners(frameToListen) +local function setUpListeners( + labelToListen: TextLabel & { + inside: BoolValue, + Parent: Frame, -- but has mousebutton1click? hmm... todo: investigate - Heliodex + } +) local fadeSpeed = 0.1 - frameToListen.Parent.MouseEnter:connect(function() - if frameToListen:FindFirstChild "inside" then - frameToListen.inside.Value = true - wait(1.2) - if frameToListen.inside.Value then - while - frameToListen.inside.Value - and frameToListen.BackgroundTransparency > 0 - do - frameToListen.BackgroundTransparency = frameToListen.BackgroundTransparency - - fadeSpeed - frameToListen.TextTransparency = frameToListen.TextTransparency - - fadeSpeed - RunService.Heartbeat:wait() - end - end + labelToListen.Parent.MouseEnter:connect(function() + if not labelToListen:FindFirstChild "inside" then + return + end + labelToListen.inside.Value = true + wait(1.2) + if not labelToListen.inside.Value then + return + end + + while + labelToListen.inside.Value + and labelToListen.BackgroundTransparency > 0 + do + labelToListen.BackgroundTransparency = labelToListen.BackgroundTransparency + - fadeSpeed + labelToListen.TextTransparency = labelToListen.TextTransparency + - fadeSpeed + RunService.Heartbeat:wait() end end) @@ -65,11 +73,11 @@ local function setUpListeners(frameToListen) killFrame.TextTransparency = 1 end - frameToListen.Parent.MouseLeave:connect(function() - killTip(frameToListen) + labelToListen.Parent.MouseLeave:connect(function() + killTip(labelToListen) end) - frameToListen.Parent.MouseButton1Click:connect(function() - killTip(frameToListen) + labelToListen.Parent.MouseButton1Click:connect(function() + killTip(labelToListen) end) end diff --git a/luau/37801172.luau b/luau/37801172.luau index 37493da..5c89922 100644 --- a/luau/37801172.luau +++ b/luau/37801172.luau @@ -36,7 +36,8 @@ local screenGui = CoreGui:FindFirstChild "RobloxGui" :: ScreenGui & { Backpack: Frame, CurrentLoadout: Frame, } -screenGui.Name = "MercuryGui" -- lmao lel lol lmfao +-- screenGui.Name = "MercuryGui" -- "it wasn't meant to be" - Heliodex +-- renaming the RobloxGui seems to break the camera local scripts = { [36868950] = "CoreScripts/ToolTip", -- ToolTipper (creates tool tips for gui) @@ -45,7 +46,6 @@ local scripts = { [48488451] = "CoreScripts/PopupScript", -- Popup Script [48488398] = "CoreScripts/NotificationScript", -- Friend Notification Script (probably can use this script to expand out to other notifications) [97188756] = "CoreScripts/ChatScript", -- Chat script - [107893730] = "CoreScripts/PurchasePromptScript", -- Purchase Prompt Script } for id, path in pairs(scripts) do diff --git a/luau/39250920.luau b/luau/39250920.luau index 88d1b83..20cbabc 100644 --- a/luau/39250920.luau +++ b/luau/39250920.luau @@ -1,5 +1,5 @@ --!strict --- CoreGui.MercuryGui.CoreScripts/MainBotChatScript +-- CoreGui.RobloxGui.CoreScripts/MainBotChatScript print "[Mercury]: Loaded corescript 39250920" local News = require "../Modules/New" @@ -9,16 +9,18 @@ local Hydrate = News.Hydrate local InsertService = game:GetService "InsertService" local RunService = game:GetService "RunService" -local function waitForProperty(instance, name) +local function waitForProperty(instance, name: string) while not instance[name] do instance.Changed:wait() end end -local function waitForChild(instance, name) +local function waitForChild(instance: Instance, name: string) while not instance:FindFirstChild(name) do instance.ChildAdded:wait() + return instance:FindFirstChild(name) end + return nil end local mainFrame: Frame & { @@ -42,11 +44,11 @@ local dialogConnections = {} local gui waitForChild(game, "CoreGui") -waitForChild(game.CoreGui, "MercuryGui") -if game.CoreGui.MercuryGui:FindFirstChild "ControlFrame" then - gui = game.CoreGui.MercuryGui.ControlFrame +waitForChild(game.CoreGui, "RobloxGui") +if game.CoreGui.RobloxGui:FindFirstChild "ControlFrame" then + gui = game.CoreGui.RobloxGui.ControlFrame else - gui = game.CoreGui.MercuryGui + gui = game.CoreGui.RobloxGui end local function currentTone() @@ -393,7 +395,7 @@ local function newChoice(numberText) Size = UDim2.new(1, -32, 1, -4), TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top, - TextWrap = true, + TextWrapped = true, RobloxLocked = true, }, } diff --git a/luau/45284430.luau b/luau/45284430.luau index ed4151b..9d69132 100644 --- a/luau/45284430.luau +++ b/luau/45284430.luau @@ -30,13 +30,11 @@ local function ScopedConnect( if syncFunc then syncFunc() end - else + elseif eventConnection then --Probably leaving the world, so disconnect for now - if eventConnection then - eventConnection:disconnect() - if removeFunc then - removeFunc() - end + eventConnection:disconnect() + if removeFunc then + removeFunc() end end end @@ -177,7 +175,7 @@ function RbxGui.CreateMessageDialog(title, message, buttons) BackgroundTransparency = 1, Font = Enum.Font.Arial, FontSize = Enum.FontSize.Size18, - TextWrap = true, + TextWrapped = true, TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top, }, @@ -218,7 +216,7 @@ function RbxGui.CreateStyledMessageDialog(title, message, style, buttons) BackgroundTransparency = 1, Font = Enum.Font.Arial, FontSize = Enum.FontSize.Size18, - TextWrap = true, + TextWrapped = true, TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top, }, @@ -266,7 +264,7 @@ function RbxGui.CreateDropDownMenu( local dropDownMenu = New "TextButton" { Name = "DropDownMenuButton", - TextWrap = true, + TextWrapped = true, TextColor3 = Color3.new(1, 1, 1), Text = "Choose One", Font = Enum.Font.ArialBold, @@ -323,7 +321,7 @@ function RbxGui.CreateDropDownMenu( BackgroundColor3 = Color3.new(1, 1, 1), Font = Enum.Font.Arial, FontSize = Enum.FontSize.Size18, - TextWrap = true, + TextWrapped = true, ZIndex = 2, } @@ -361,13 +359,15 @@ function RbxGui.CreateDropDownMenu( end local children = droppedDownMenu:GetChildren() - if children then - for _, child in ipairs(children) do - if child.Name == "ChoiceButton" then - child.ZIndex = baseZIndex + 2 - elseif child.Name == "ClickCaptureButton" then - child.ZIndex = baseZIndex - end + if not children then + return + end + + for _, child in ipairs(children) do + if child.Name == "ChoiceButton" then + child.ZIndex = baseZIndex + 2 + elseif child.Name == "ClickCaptureButton" then + child.ZIndex = baseZIndex end end end @@ -418,11 +418,7 @@ function RbxGui.CreateDropDownMenu( areaSoak.Visible = not areaSoak.Visible dropDownMenu.Visible = not dropDownSelected droppedDownMenu.Visible = dropDownSelected - if dropDownSelected then - setZIndex(4) - else - setZIndex(2) - end + setZIndex(dropDownSelected and 4 or 2) if useScrollButtons then updateScroll() end @@ -2479,7 +2475,7 @@ local function CreateBasicTutorialPage( Font = Enum.Font.ArialBold, TextColor3 = Color3.new(1, 1, 1), TextXAlignment = Enum.TextXAlignment.Center, - TextWrap = true, + TextWrapped = true, Size = UDim2.new(1, -55, 0, 22), Position = UDim2.new(0, 0, 0, 0), }, @@ -2607,7 +2603,7 @@ function RbxGui.CreateTextTutorialPage(name, text, skipTutorial) BackgroundTransparency = 1, TextColor3 = Color3.new(1, 1, 1), Text = text, - TextWrap = true, + TextWrapped = true, TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Center, Font = Enum.Font.Arial, @@ -2959,7 +2955,7 @@ function RbxGui.CreateSetPanel( FontSize = Enum.FontSize.Size24, Text = "", TextColor3 = Color3.new(1, 1, 1), - TextWrap = true, + TextWrapped = true, TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top, }, diff --git a/luau/46295863.luau b/luau/46295863.luau index ac7d3ee..fd46b61 100644 --- a/luau/46295863.luau +++ b/luau/46295863.luau @@ -1,5 +1,5 @@ --!strict --- CoreGui.MercuryGui.CoreScripts/Settings +-- CoreGui.RobloxGui.CoreScripts/Settings print "[Mercury]: Loaded corescript 46295863" local News = require "../Modules/New" @@ -23,10 +23,9 @@ local function waitForProperty(instance, property) end -- A Few Script Globals -local gui = script.Parent -if gui:FindFirstChild "ControlFrame" then - gui = gui.ControlFrame -end +local mercuryGui = script.Parent :: ScreenGui & { ControlFrame: Frame } +local gui = mercuryGui:FindFirstChild "ControlFrame" and mercuryGui.ControlFrame + or mercuryGui local RbxGui local helpButton, updateCameraDropDownSelection, updateVideoCaptureDropDownSelection @@ -56,7 +55,7 @@ local ok, isMac = pcall(function() end) macClient = ok and isMac -local function Color3I(r, g, b) +local function Colour3(r: number, g: number, b: number) return Color3.new(r / 255, g / 255, b / 255) end @@ -343,8 +342,8 @@ local function createHelpDialog(baseZIndex) Active = true, Visible = false, Size = UDim2.new(1, 0, 1, 0), - BackgroundColor3 = Color3I(51, 51, 51), - BorderColor3 = Color3I(27, 42, 53), + BackgroundColor3 = Colour3(51, 51, 51), + BorderColor3 = Colour3(27, 42, 53), BackgroundTransparency = 0.4, ZIndex = baseZIndex + 1, } @@ -500,7 +499,7 @@ local function createLeaveConfirmationMenu(baseZIndex, shield) Name = "LeaveText", Text = "Leave this game?", Size = UDim2.new(1, 0, 0.8, 0), - TextWrap = true, + TextWrapped = true, TextColor3 = Color3.new(1, 1, 1), Font = Enum.Font.ArialBold, FontSize = Enum.FontSize.Size36, @@ -559,7 +558,7 @@ local function createResetConfirmationMenu(baseZIndex, shield) local function resetCharacterText() return New "TextLabel" { Size = UDim2.new(1, 0, 0.8, 0), - TextWrap = true, + TextWrapped = true, TextColor3 = Color3.new(1, 1, 1), Font = Enum.Font.ArialBold, BackgroundTransparency = 1, @@ -999,7 +998,7 @@ local function createGameSettingsMenu(baseZIndex, _) local betterQualityText = Hydrate(qualityTextC()) { Name = "BetterQualityText", Text = "Better Quality", - TextWrap = true, + TextWrapped = true, Size = UDim2.new(0, 41, 0, 28), Position = UDim2.new(0, 390, 0, 269), TextColor3 = Color3.new(95, 95, 95), @@ -1049,7 +1048,7 @@ local function createGameSettingsMenu(baseZIndex, _) FontSize = Enum.FontSize.Size18, Text = "Auto", ZIndex = 1, - TextWrap = true, + TextWrapped = true, Parent = gameSettingsMenuFrame, Visible = not inStudioMode, } @@ -1471,7 +1470,7 @@ local function createGameSettingsMenu(baseZIndex, _) Position = UDim2.new(0, 32, 0, 100), Size = UDim2.new(0, 164, 0, 18), BackgroundTransparency = 1, - TextColor3 = Color3I(255, 255, 255), + TextColor3 = Colour3(255, 255, 255), TextXAlignment = Enum.TextXAlignment.Left, ZIndex = baseZIndex + 4, Parent = gameSettingsMenuFrame, @@ -1529,14 +1528,14 @@ local function createGameSettingsMenu(baseZIndex, _) FontSize = Enum.FontSize.Size18, Position = UDim2.new(0, 31, 0, 58), Size = UDim2.new(0, 224, 0, 18), - TextColor3 = Color3I(255, 255, 255), + TextColor3 = Colour3(255, 255, 255), TextXAlignment = Enum.TextXAlignment.Left, BackgroundTransparency = 1, ZIndex = baseZIndex + 4, Parent = gameSettingsMenuFrame, } - mouseLockLabel = CoreGui.MercuryGui:FindFirstChild("MouseLockLabel", true) + mouseLockLabel = CoreGui.RobloxGui:FindFirstChild("MouseLockLabel", true) local enumItems = Enum.ControlMode:GetEnumItems() local enumNames = {} @@ -1607,8 +1606,8 @@ if UserSettings then AutoButtonColor = false, Visible = false, Size = UDim2.new(1, 0, 1, 0), - BackgroundColor3 = Color3I(51, 51, 51), - BorderColor3 = Color3I(27, 42, 53), + BackgroundColor3 = Colour3(51, 51, 51), + BorderColor3 = Colour3(27, 42, 53), BackgroundTransparency = 0.4, ZIndex = baseZIndex + 2, } @@ -1663,7 +1662,7 @@ if UserSettings then end) end - CoreGui.MercuryGui.Changed:connect( + CoreGui.RobloxGui.Changed:connect( function(prop) -- We have stopped recording when we resize if prop == "AbsoluteSize" and recordingVideo then recordVideoClick( @@ -1976,8 +1975,8 @@ local function createSaveDialogs() Active = true, Visible = false, Size = UDim2.new(1, 0, 1, 0), - BackgroundColor3 = Color3I(51, 51, 51), - BorderColor3 = Color3I(27, 42, 53), + BackgroundColor3 = Colour3(51, 51, 51), + BorderColor3 = Colour3(27, 42, 53), BackgroundTransparency = 0.4, ZIndex = baseZIndex + 1, } @@ -2207,8 +2206,8 @@ local function createReportAbuseDialog() Active = true, Visible = false, Size = UDim2.new(1, 0, 1, 0), - BackgroundColor3 = Color3I(51, 51, 51), - BorderColor3 = Color3I(27, 42, 53), + BackgroundColor3 = Colour3(51, 51, 51), + BorderColor3 = Colour3(27, 42, 53), BackgroundTransparency = 0.4, ZIndex = baseZIndex + 1, } @@ -2303,7 +2302,7 @@ local function createReportAbuseDialog() New "TextLabel" { Name = "Title", Text = "Report Abuse", - TextColor3 = Color3I(221, 221, 221), + TextColor3 = Colour3(221, 221, 221), Position = UDim2.new(0.5, 0, 0, 30), Font = Enum.Font.ArialBold, FontSize = Enum.FontSize.Size36, @@ -2312,13 +2311,13 @@ local function createReportAbuseDialog() New "TextLabel" { Name = "Description", Text = "This will send a complete report to a moderator. The moderator will review the chat log and take appropriate action.", - TextColor3 = Color3I(221, 221, 221), + TextColor3 = Colour3(221, 221, 221), Position = UDim2.new(0, 0, 0, 55), Size = UDim2.new(1, 0, 0, 40), BackgroundTransparency = 1, Font = Enum.Font.Arial, FontSize = Enum.FontSize.Size18, - TextWrap = true, + TextWrapped = true, ZIndex = baseZIndex + 2, TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top, @@ -2331,7 +2330,7 @@ local function createReportAbuseDialog() FontSize = Enum.FontSize.Size18, Position = UDim2.new(0.025, 0, 0, 100), Size = UDim2.new(0.4, 0, 0, 36), - TextColor3 = Color3I(255, 255, 255), + TextColor3 = Colour3(255, 255, 255), TextXAlignment = Enum.TextXAlignment.Left, ZIndex = baseZIndex + 2, }, @@ -2343,7 +2342,7 @@ local function createReportAbuseDialog() FontSize = Enum.FontSize.Size18, Position = UDim2.new(0.025, 0, 0, 140), Size = UDim2.new(0.4, 0, 0, 36), - TextColor3 = Color3I(255, 255, 255), + TextColor3 = Colour3(255, 255, 255), TextXAlignment = Enum.TextXAlignment.Left, ZIndex = baseZIndex + 2, }, @@ -2360,7 +2359,7 @@ local function createReportAbuseDialog() FontSize = Enum.FontSize.Size18, Position = UDim2.new(0.025, 0, 0, 180), Size = UDim2.new(0.95, 0, 0, 36), - TextColor3 = Color3I(255, 255, 255), + TextColor3 = Colour3(255, 255, 255), TextXAlignment = Enum.TextXAlignment.Left, BackgroundTransparency = 1, ZIndex = baseZIndex + 2, @@ -2405,7 +2404,7 @@ local function createReportAbuseDialog() Name = "ShortDescriptionWrapper", Position = UDim2.new(0.025, 0, 0, 220), Size = UDim2.new(0.95, 0, 1, -310), - BackgroundColor3 = Color3I(0, 0, 0), + BackgroundColor3 = Colour3(0, 0, 0), BorderSizePixel = 0, ZIndex = baseZIndex + 2, Parent = reportAbuseFrame, @@ -2419,11 +2418,11 @@ local function createReportAbuseDialog() FontSize = Enum.FontSize.Size18, Position = UDim2.new(0, 3, 0, 3), Size = UDim2.new(1, -6, 1, -6), - TextColor3 = Color3I(255, 255, 255), + TextColor3 = Colour3(255, 255, 255), TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top, - TextWrap = true, - BackgroundColor3 = Color3I(0, 0, 0), + TextWrapped = true, + BackgroundColor3 = Colour3(0, 0, 0), BorderSizePixel = 0, ZIndex = baseZIndex + 2, Parent = shortDescriptionWrapper, @@ -2440,7 +2439,7 @@ local function createReportAbuseDialog() AutoButtonColor = true, Style = Enum.ButtonStyle.RobloxButtonDefault, Text = "Submit Report", - TextColor3 = Color3I(255, 255, 255), + TextColor3 = Colour3(255, 255, 255), ZIndex = baseZIndex + 2, Parent = reportAbuseFrame, } @@ -2476,7 +2475,7 @@ local function createReportAbuseDialog() AutoButtonColor = true, Style = Enum.ButtonStyle.RobloxButtonDefault, Text = "Cancel", - TextColor3 = Color3I(255, 255, 255), + TextColor3 = Colour3(255, 255, 255), ZIndex = baseZIndex + 2, Parent = reportAbuseFrame, } diff --git a/luau/48488235.luau b/luau/48488235.luau index 8e7ae5a..14b507d 100644 --- a/luau/48488235.luau +++ b/luau/48488235.luau @@ -1,5 +1,5 @@ --!strict --- CoreGui.MercuryGui.CoreScripts/PlayerListScript +-- CoreGui.RobloxGui.CoreScripts/PlayerListScript print "[Mercury]: Loaded corescript 48488235" local RunService = game:GetService "RunService" @@ -435,7 +435,7 @@ local AbuseSettingsFrame = New "Frame" { BackgroundTransparency = 1, Font = Enum.Font.Arial, FontSize = Enum.FontSize.Size18, - TextWrap = true, + TextWrapped = true, TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top, }, @@ -532,7 +532,7 @@ local OriginalAbuseDescriptionBox = New "TextBox" { TextColor3 = Colour3(255, 255, 255), TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Top, - TextWrap = true, + TextWrapped = true, BackgroundColor3 = Colour3(0, 0, 0), BorderSizePixel = 0, } @@ -761,9 +761,9 @@ local PrivilegeLevel = { Banned = 0, } --- local IsPersonalServer = not not game.Workspace:FindFirstChild "PSVariable" +-- local IsPersonalServer = workspace:FindFirstChild "PSVariable" --- game.Workspace.ChildAdded:connect(function(nchild) +-- workspace.ChildAdded:connect(function(nchild) -- if nchild.Name == "PSVariable" and nchild:IsA "BoolValue" then -- IsPersonalServer = true -- end @@ -3395,4 +3395,4 @@ BaseUpdate() -- UGGGLY, find a better way later -- wait(2) --- IsPersonalServer = not not game.Workspace:FindFirstChild "PSVariable" +-- IsPersonalServer = workspace:FindFirstChild "PSVariable" diff --git a/luau/48488398.luau b/luau/48488398.luau index a10eb30..ba6cc67 100644 --- a/luau/48488398.luau +++ b/luau/48488398.luau @@ -1,4 +1,4 @@ --- CoreGui.MercuryGui.CoreScripts/NotificationScript +-- CoreGui.RobloxGui.CoreScripts/NotificationScript print "[Mercury]: Loaded corescript 48488398" local GuiService = game:GetService "GuiService" diff --git a/luau/48488451.luau b/luau/48488451.luau index 9402de0..010e110 100644 --- a/luau/48488451.luau +++ b/luau/48488451.luau @@ -1,4 +1,4 @@ --- CoreGui.MercuryGui.CoreScripts/PopupScript +-- CoreGui.RobloxGui.CoreScripts/PopupScript print "[Mercury]: Loaded corescript 48488451" local News = require "../Modules/New" @@ -37,7 +37,7 @@ local popupFrame = New "Frame" { BackgroundTransparency = 1, Text = "Hello I'm a popup", TextColor3 = Color3.new(248 / 255, 248 / 255, 248 / 255), - TextWrap = true, + TextWrapped = true, ZIndex = 5, }, } diff --git a/luau/53878047.luau b/luau/53878047.luau index 0c6b57f..feb7cda 100644 --- a/luau/53878047.luau +++ b/luau/53878047.luau @@ -1,4 +1,4 @@ --- CoreGui.MercuryGui.CoreScripts/BackpackScripts/BackpackBuild +-- CoreGui.RobloxGui.CoreScripts/BackpackScripts/BackpackBuild print "[Mercury]: Loaded corescript 53878047" local News = require "../Modules/New" @@ -127,7 +127,7 @@ local CurrentLoadout = New "Frame" { TextStrokeTransparency = 0, Font = Enum.Font.ArialBold, FontSize = Enum.FontSize.Size14, - -- TextWrap = true, + -- TextWrapped = true, Size = UDim2.new(1, 60, 0, 20), Position = UDim2.new(0, -30, 0, -30), }, @@ -153,7 +153,7 @@ local CurrentLoadout = New "Frame" { Size = UDim2.new(1, 16, 1, 16), Text = "", TextColor3 = Color3.new(1, 1, 1), - TextWrap = true, + TextWrapped = true, ZIndex = 5.0, }, Hydrate(SlotNumber()) { @@ -311,7 +311,7 @@ New "Frame" { TextColor3 = Color3.new(1, 1, 1), TextXAlignment = Enum.TextXAlignment.Left, ZIndex = 2, - TextWrap = true, + TextWrapped = true, Text = "Search...", }, }, @@ -418,7 +418,7 @@ New "Frame" { Size = UDim2.new(1, 6, 1, 5), Text = "", TextColor3 = Color3.new(1, 1, 1), - TextWrap = true, + TextWrapped = true, ZIndex = 9, }, }, @@ -501,7 +501,7 @@ New "Frame" { Text = "", ZIndex = 2, TextColor3 = Color3.new(1, 1, 1), - TextWrap = true, + TextWrapped = true, }, }, }, diff --git a/luau/53878057.luau b/luau/53878057.luau index f063237..716af5c 100644 --- a/luau/53878057.luau +++ b/luau/53878057.luau @@ -1,4 +1,4 @@ --- CoreGui.MercuryGui.CurrentLoadout.CoreScripts/BackpackScript +-- CoreGui.RobloxGui.CurrentLoadout.CoreScripts/BackpackScript print "[Mercury]: Loaded corescript 53878057" local CoreGui = game:GetService "CoreGui" @@ -23,7 +23,7 @@ local currentLoadout = script.Parent local StaticTabName = "gear" local backpackEnabled = true -local mercuryGui = CoreGui:FindFirstChild "MercuryGui" +local mercuryGui = CoreGui:FindFirstChild "RobloxGui" assert(mercuryGui) local controlFrame = waitForChild(mercuryGui, "ControlFrame") diff --git a/luau/60595411.luau b/luau/60595411.luau index 958bf99..118419a 100644 --- a/luau/60595411.luau +++ b/luau/60595411.luau @@ -39,7 +39,7 @@ function RbxUtility.SelectTerrainRegion( selectEmptyCells: boolean, selectionParent: Instance ) - local terrain = game.Workspace:FindFirstChild "Terrain" :: Terrain + local terrain = workspace:FindFirstChild "Terrain" :: Terrain if not terrain then return end @@ -73,7 +73,7 @@ function RbxUtility.SelectTerrainRegion( local selectionContainer = New "Model" { Name = "SelectionContainer", Archivable = false, - Parent = selectionParent or game.Workspace, + Parent = selectionParent or workspace, } local updateSelection -- function we return to allow user to update selection @@ -386,7 +386,7 @@ Some example usages: A simple example which uses the Create function to create a model object and assign two of it's properties. local model = Create'Model'{ Name = 'A New model', - Parent = game.Workspace, + Parent = workspace, } diff --git a/luau/73157242.luau b/luau/73157242.luau index f86d604..77b86f2 100644 --- a/luau/73157242.luau +++ b/luau/73157242.luau @@ -4,18 +4,22 @@ print "[Mercury]: Loaded corescript 73157242" local ChangeHistoryService = game:GetService "ChangeHistoryService" local InsertService = game:GetService "InsertService" +local News = require "../Modules/New" +local New = News.New +local Hydrate = News.Hydrate + local RbxStamper = {} --- Do a line/plane intersection. The line starts at the camera. The plane is at y == 0, normal(0, 1, 0) +-- Do a line/plane intersection. The line starts at the camera. The plane is at y == 0, normal(0, 1, 0) -- -- vectorPos - End point of the line. -- -- Return: -- cellPos - The terrain cell intersection point if there is one, vectorPos if there isn't. --- hit - Whether there was a plane intersection. Value is true if there was, false if not. +-- hit - Whether there was a plane intersection. Value is true if there was, false if not. local function PlaneIntersection(vectorPos) local hit = false - local currCamera = game.Workspace.CurrentCamera + local currCamera = workspace.CurrentCamera local startPos = Vector3.new( currCamera.CoordinateFrame.p.X, currCamera.CoordinateFrame.p.Y, @@ -30,7 +34,7 @@ local function PlaneIntersection(vectorPos) local t = normal:Dot(p3 - startPos) / startEndDot if t >= 0 and t <= 1 then local intersection = ((endPos - startPos) * t) + startPos - cellPos = game.Workspace.Terrain:WorldToCell(intersection) + cellPos = workspace.Terrain:WorldToCell(intersection) hit = true end end @@ -45,15 +49,15 @@ end -- mouse - Mouse to check the .hit for. -- -- Return: --- cellPos - Cell position hit. Nil if none. +-- cellPos - Cell position hit. Nil if none. local function GetTerrainForMouse(mouse) -- There was no target, so all it could be is a plane intersection. - -- Check for a plane intersection. If there isn't one then nothing will get hit. - local cell = game.Workspace.Terrain:WorldToCellPreferSolid( + -- Check for a plane intersection. If there isn't one then nothing will get hit. + local cell = workspace.Terrain:WorldToCellPreferSolid( Vector3.new(mouse.hit.x, mouse.hit.y, mouse.hit.z) ) -- If nothing was hit, do the plane intersection. - if 0 == game.Workspace.Terrain:GetCell(cell.X, cell.Y, cell.Z).Value then + if 0 == workspace.Terrain:GetCell(cell.X, cell.Y, cell.Z).Value then cell = nil local planeLoc, hit = PlaneIntersection( Vector3.new(mouse.hit.x, mouse.hit.y, mouse.hit.z) @@ -107,7 +111,7 @@ end local cluster local function clusterPartsInRegion(startVector, endVector) - cluster = game.Workspace:FindFirstChild "Terrain" + cluster = workspace:FindFirstChild "Terrain" local startCell = cluster:WorldToCell(startVector) local endCell = cluster:WorldToCell(endVector) @@ -180,7 +184,7 @@ local function setSeatEnabledStatus(model, isEnabled) end else -- put a weld called "SeatWeld" in every seat - -- this tricks it into thinking there's already someone sitting there, and it won't make you sit XD + -- this tricks it into thinking there's already someone sitting there, and it won't make you sit XD for i = 1, #seatList do local fakeWeld = Instance.new "Weld" fakeWeld.Name = "SeatWeld" @@ -249,7 +253,7 @@ end local function calcRayHitTime(rayStart, raySlope, intersectionPlane) if math.abs(raySlope) < 0.01 then return 0 - end -- 0 slope --> we just say intersection time is 0, and sidestep this dimension + end -- 0 slope --> we just say intersection time is 0, and sidestep this dimension return (intersectionPlane - rayStart) / raySlope end @@ -409,20 +413,19 @@ local function getBoundingBoxInWorldCoordinates(partOrModel) end local function getTargetPartBoundingBox(targetPart) - if targetPart.Parent:FindFirstChild "RobloxModel" ~= nil then + if targetPart.Parent:FindFirstChild "RobloxModel" then return getBoundingBox2(targetPart.Parent) end return getBoundingBox2(targetPart) end local function getMouseTargetCFrame(targetPart) - if targetPart.Parent:FindFirstChild "RobloxModel" ~= nil then - if targetPart.Parent:IsA "Tool" then - return targetPart.Parent.Handle.CFrame - end - return targetPart.Parent:GetModelCFrame() + if not targetPart.Parent:FindFirstChild "RobloxModel" then + return targetPart.CFrame + elseif targetPart.Parent:IsA "Tool" then + return targetPart.Parent.Handle.CFrame end - return targetPart.CFrame + return targetPart.Parent:GetModelCFrame() end local function isBlocker(part: Instance) -- returns whether or not we want to cancel the stamp because we're blocked by this part @@ -448,7 +451,7 @@ local function spaceAboveCharacter( newTorsoY, stampData: Instance ) - local partsAboveChar = game.Workspace:FindPartsInRegion3( + local partsAboveChar = workspace:FindPartsInRegion3( Region3.new( Vector3.new(charTorso.Position.X, newTorsoY, charTorso.Position.Z) - Vector3.new(0.75, 2.75, 0.75), @@ -476,7 +479,12 @@ local function spaceAboveCharacter( ) end -local function findConfigAtMouseTarget(Mouse: Mouse, stampData: Instance) +local function findConfigAtMouseTarget( + Mouse: Mouse, + stampData: Instance & { + CurrentParts: Instance, + } +) -- *Critical Assumption* : -- This function assumes the target CF axes are orthogonal with the target bounding box faces -- And, it assumes the insert CF axes are orthongonal with the insert bounding box faces @@ -539,15 +547,12 @@ local function findConfigAtMouseTarget(Mouse: Mouse, stampData: Instance) hitPlane = false return admissibleConfig, targetConfig end - targetPart = game.Workspace.Terrain + targetPart = workspace.Terrain hitPlane = true -- Take into account error that will occur. cellPos = Vector3.new(cellPos.X - 1, cellPos.Y, cellPos.Z) - mouseHitInWorld = game.Workspace.Terrain:CellCenterToWorld( - cellPos.x, - cellPos.y, - cellPos.z - ) + mouseHitInWorld = + workspace.Terrain:CellCenterToWorld(cellPos.x, cellPos.y, cellPos.z) end -- test mouse hit location @@ -557,7 +562,7 @@ local function findConfigAtMouseTarget(Mouse: Mouse, stampData: Instance) if targetPart:IsA "Terrain" then if not cluster then - cluster = game.Workspace:FindFirstChild "Terrain" :: Terrain + cluster = workspace:FindFirstChild "Terrain" :: Terrain end local cellID = cluster:WorldToCellPreferSolid(mouseHitInWorld) if hitPlane then @@ -565,19 +570,15 @@ local function findConfigAtMouseTarget(Mouse: Mouse, stampData: Instance) end targetCFrame = CFrame.new( - game.Workspace.Terrain:CellCenterToWorld( - cellID.x, - cellID.y, - cellID.z - ) + workspace.Terrain:CellCenterToWorld(cellID.x, cellID.y, cellID.z) ) end local mouseHitInTarget = targetCFrame:pointToObjectSpace(mouseHitInWorld) local targetVectorInWorld = Vector3.new(0, 0, 0) if Mouse then - -- DON'T WANT THIS IN TERMS OF THE MODEL CFRAME! (.TargetSurface is in terms of the part CFrame, so this would break, right? [HotThoth]) - -- (ideally, we would want to make the Mouse.TargetSurface a model-targetsurface instead, but for testing will be using the converse) + -- DON'T WANT THIS IN TERMS OF THE MODEL CFRAME! (.TargetSurface is in terms of the part CFrame, so this would break, right? [HotThoth]) + -- (ideally, we would want to make the Mouse.TargetSurface a model-targetsurface instead, but for testing will be using the converse) --targetVectorInWorld = targetCFrame:vectorToWorldSpace(Vector3.FromNormalId(Mouse.TargetSurface)) targetVectorInWorld = targetPart.CFrame:vectorToWorldSpace( Vector3.FromNormalId(Mouse.TargetSurface) @@ -587,7 +588,7 @@ local function findConfigAtMouseTarget(Mouse: Mouse, stampData: Instance) local hitFace = modelTargetSurface( targetPart.Parent, Mouse.Hit.p, - game.Workspace.CurrentCamera.CoordinateFrame.p + workspace.CurrentCamera.CoordinateFrame.p ) -- best, if you get it right local WORLD_AXES = { Vector3.new(1, 0, 0), @@ -757,6 +758,107 @@ function RbxStamper.CanEditRegion(partOrModel, EditRegion) -- todo: use model an return true, false end +local function UnlockInstances(object) + if object:IsA "BasePart" then + object.Locked = false + end + for _, child in pairs(object:GetChildren()) do + UnlockInstances(child) + end +end + +local function closestTerrainMaterialColour(terrainValue) + if terrainValue == 1 then + return BrickColor.new "Bright green" + elseif terrainValue == 2 then + return BrickColor.new "Bright yellow" + elseif terrainValue == 3 then + return BrickColor.new "Bright red" + elseif terrainValue == 4 then + return BrickColor.new "Sand red" + elseif terrainValue == 5 then + return BrickColor.new "Black" + elseif terrainValue == 6 then + return BrickColor.new "Dark stone grey" + elseif terrainValue == 7 then + return BrickColor.new "Sand blue" + elseif terrainValue == 8 then + return BrickColor.new "Deep orange" + elseif terrainValue == 9 then + return BrickColor.new "Dark orange" + elseif terrainValue == 10 then + return BrickColor.new "Reddish brown" + elseif terrainValue == 11 then + return BrickColor.new "Light orange" + elseif terrainValue == 12 then + return BrickColor.new "Light stone grey" + elseif terrainValue == 13 then + return BrickColor.new "Sand green" + elseif terrainValue == 14 then + return BrickColor.new "Medium stone grey" + elseif terrainValue == 15 then + return BrickColor.new "Really red" + elseif terrainValue == 16 then + return BrickColor.new "Really blue" + elseif terrainValue == 17 then + return BrickColor.new "Bright blue" + end + return BrickColor.new "Bright green" +end + +local function setupFakeTerrainPart(cellMat, cellType, cellOrient) + local newTerrainPiece + if cellType == 1 or cellType == 4 then + newTerrainPiece = New "WedgePart" { + formFactor = "Custom", + } + elseif cellType == 2 then + newTerrainPiece = Instance.new "CornerWedgePart" + else + newTerrainPiece = New "Part" { + formFactor = "Custom", + } + end + + Hydrate(newTerrainPiece) { + Name = "MegaClusterCube", + Size = Vector3.new(4, 4, 4), + BottomSurface = "Smooth", + TopSurface = "Smooth", + } + + -- can add decals or textures here if feeling particularly adventurous... for now, can make a table of look-up colors + newTerrainPiece.BrickColor = closestTerrainMaterialColour(cellMat) + + local sideways = 0 + local flipped = math.pi + if cellType == 4 then + sideways = -math.pi / 2 + end + if cellType == 2 or cellType == 3 then + flipped = 0 + end + newTerrainPiece.CFrame = + CFrame.Angles(0, math.pi / 2 * cellOrient + flipped, sideways) + + if cellType == 3 then + New "SpecialMesh" { + MeshType = "FileMesh", + MeshId = "http://banland.xyz/asset?id=66832495", + Scale = Vector3.new(2, 2, 2), + Parent = newTerrainPiece, + } + end + + New "Vector3Value" { + Value = Vector3.new(cellMat, cellType, cellOrient), + Name = "ClusterMaterial", + Parent = newTerrainPiece, + } + + return newTerrainPiece +end + function RbxStamper.GetStampModel(assetId, terrainShape, useAssetVersionId) if assetId == 0 then return nil, "No Asset" @@ -764,101 +866,6 @@ function RbxStamper.GetStampModel(assetId, terrainShape, useAssetVersionId) return nil, "Negative Asset" end - local function UnlockInstances(object) - if object:IsA "BasePart" then - object.Locked = false - end - for _, child in pairs(object:GetChildren()) do - UnlockInstances(child) - end - end - - local function getClosestColorToTerrainMaterial(terrainValue) - if terrainValue == 1 then - return BrickColor.new "Bright green" - elseif terrainValue == 2 then - return BrickColor.new "Bright yellow" - elseif terrainValue == 3 then - return BrickColor.new "Bright red" - elseif terrainValue == 4 then - return BrickColor.new "Sand red" - elseif terrainValue == 5 then - return BrickColor.new "Black" - elseif terrainValue == 6 then - return BrickColor.new "Dark stone grey" - elseif terrainValue == 7 then - return BrickColor.new "Sand blue" - elseif terrainValue == 8 then - return BrickColor.new "Deep orange" - elseif terrainValue == 9 then - return BrickColor.new "Dark orange" - elseif terrainValue == 10 then - return BrickColor.new "Reddish brown" - elseif terrainValue == 11 then - return BrickColor.new "Light orange" - elseif terrainValue == 12 then - return BrickColor.new "Light stone grey" - elseif terrainValue == 13 then - return BrickColor.new "Sand green" - elseif terrainValue == 14 then - return BrickColor.new "Medium stone grey" - elseif terrainValue == 15 then - return BrickColor.new "Really red" - elseif terrainValue == 16 then - return BrickColor.new "Really blue" - elseif terrainValue == 17 then - return BrickColor.new "Bright blue" - end - return BrickColor.new "Bright green" - end - - local function setupFakeTerrainPart(cellMat, cellType, cellOrient) - local newTerrainPiece - if cellType == 1 or cellType == 4 then - newTerrainPiece = Instance.new "WedgePart" - newTerrainPiece.formFactor = "Custom" - elseif cellType == 2 then - newTerrainPiece = Instance.new "CornerWedgePart" - else - newTerrainPiece = Instance.new "Part" - newTerrainPiece.formFactor = "Custom" - end - newTerrainPiece.Name = "MegaClusterCube" - newTerrainPiece.Size = Vector3.new(4, 4, 4) - newTerrainPiece.BottomSurface = "Smooth" - newTerrainPiece.TopSurface = "Smooth" - - -- can add decals or textures here if feeling particularly adventurous... for now, can make a table of look-up colors - newTerrainPiece.BrickColor = getClosestColorToTerrainMaterial(cellMat) - - local sideways = 0 - local flipped = math.pi - if cellType == 4 then - sideways = -math.pi / 2 - end - if cellType == 2 or cellType == 3 then - flipped = 0 - end - newTerrainPiece.CFrame = - CFrame.Angles(0, math.pi / 2 * cellOrient + flipped, sideways) - - if cellType == 3 then - local inverseCornerWedgeMesh = Instance.new "SpecialMesh" - inverseCornerWedgeMesh.MeshType = "FileMesh" - inverseCornerWedgeMesh.MeshId = - "http://banland.xyz/asset?id=66832495" - inverseCornerWedgeMesh.Scale = Vector3.new(2, 2, 2) - inverseCornerWedgeMesh.Parent = newTerrainPiece - end - - local materialTag = Instance.new "Vector3Value" - materialTag.Value = Vector3.new(cellMat, cellType, cellOrient) - materialTag.Name = "ClusterMaterial" - materialTag.Parent = newTerrainPiece - - return newTerrainPiece - end - -- This call will cause a "wait" until the data comes back -- below we wait a max of 8 seconds before deciding to bail out on loading local root @@ -937,31 +944,26 @@ function RbxStamper.GetStampModel(assetId, terrainShape, useAssetVersionId) end end - if terrainShape then - if root.Name == "MegaClusterCube" then - if terrainShape == 6 then -- insert an autowedging tag - local autowedgeTag = Instance.new "BoolValue" - autowedgeTag.Name = "AutoWedge" - autowedgeTag.Parent = root - else - local clusterTag = root:FindFirstChild "ClusterMaterial" - if clusterTag then - if clusterTag:IsA "Vector3Value" then - root = setupFakeTerrainPart( - clusterTag.Value.X, - terrainShape, - clusterTag.Value.Z - ) - else - root = setupFakeTerrainPart( - clusterTag.Value, - terrainShape, - 0 - ) - end + if terrainShape and root.Name == "MegaClusterCube" then + if terrainShape == 6 then -- insert an autowedging tag + local autowedgeTag = Instance.new "BoolValue" + autowedgeTag.Name = "AutoWedge" + autowedgeTag.Parent = root + else + local clusterTag = root:FindFirstChild "ClusterMaterial" + if clusterTag then + if clusterTag:IsA "Vector3Value" then + root = setupFakeTerrainPart( + clusterTag.Value.X, + terrainShape, + clusterTag.Value.Z + ) else - root = setupFakeTerrainPart(1, terrainShape, 0) + root = + setupFakeTerrainPart(clusterTag.Value, terrainShape, 0) end + else + root = setupFakeTerrainPart(1, terrainShape, 0) end end end @@ -969,26 +971,629 @@ function RbxStamper.GetStampModel(assetId, terrainShape, useAssetVersionId) return root end +local function isMegaClusterPart(stampData: { + CurrentParts: BasePart, +}) + if not (stampData and stampData.CurrentParts) then + return false + end + + return ( + stampData.CurrentParts:FindFirstChild("ClusterMaterial", true) + or (stampData.CurrentParts.Name == "MegaClusterCube") + ) +end + +type HighScalabilityLine = { + Adorn: Instance, + Start: Vector3, + End: Vector3, + Dimensions: number, + MoreLines: { Vector3 }, + MorePoints: { Vector3 }, + InternalLine: Vector3, + AdornPart: BasePart, +} + +local function DoHighScalabilityRegionSelect( + stampData: { + CurrentParts: BasePart, + }, + HighScalabilityLine: HighScalabilityLine +) + local megaCube = stampData.CurrentParts:FindFirstChild "MegaClusterCube" + if not megaCube then + if stampData.CurrentParts.Name ~= "MegaClusterCube" then + return + end + megaCube = stampData.CurrentParts + end + + HighScalabilityLine.End = megaCube.CFrame.p + local line + local line2 = Vector3.new(0, 0, 0) + local line3 = Vector3.new(0, 0, 0) + + if HighScalabilityLine.Dimensions == 1 then + -- extract the line from these positions and limit to a 2D plane made from 2 of the world axes + -- then use dominating axis to limit line to be at 45-degree intervals + -- will use this internal representation of the line for the actual stamping + line = (HighScalabilityLine.End - HighScalabilityLine.Start) + + if math.abs(line.X) < math.abs(line.Y) then + if math.abs(line.X) < math.abs(line.Z) then + -- limit to Y/Z plane, domination unknown + local newY, newZ + if math.abs(line.Y) > math.abs(line.Z) then + newY, newZ = truncateToCircleEighth(line.Y, line.Z) + else + newZ, newY = truncateToCircleEighth(line.Z, line.Y) + end + line = Vector3.new(0, newY, newZ) + else + -- limit to X/Y plane, with Y dominating + local newY, newX = truncateToCircleEighth(line.Y, line.X) + line = Vector3.new(newX, newY, 0) + end + else + if math.abs(line.Y) < math.abs(line.Z) then + -- limit to X/Z plane, domination unknown + local newX, newZ + if math.abs(line.X) > math.abs(line.Z) then + newX, newZ = truncateToCircleEighth(line.X, line.Z) + else + newZ, newX = truncateToCircleEighth(line.Z, line.X) + end + line = Vector3.new(newX, 0, newZ) + else + -- limit to X/Y plane, with X dominating + local newX, newY = truncateToCircleEighth(line.X, line.Y) + line = Vector3.new(newX, newY, 0) + end + end + HighScalabilityLine.InternalLine = line + elseif HighScalabilityLine.Dimensions == 2 then + line = HighScalabilityLine.MoreLines[1] + line2 = HighScalabilityLine.End - HighScalabilityLine.MorePoints[1] + + -- take out any component of line2 along line1, so you get perpendicular to line1 component + line2 -= line.unit * line.unit:Dot(line2) + + local tempCFrame = CFrame.new( + HighScalabilityLine.Start, + HighScalabilityLine.Start + line + ) + + -- then zero out whichever is the smaller component + local yAxis = tempCFrame:vectorToWorldSpace(Vector3.new(0, 1, 0)) + local xAxis = tempCFrame:vectorToWorldSpace(Vector3.new(1, 0, 0)) + + local xComp = xAxis:Dot(line2) + local yComp = yAxis:Dot(line2) + + if math.abs(yComp) > math.abs(xComp) then + line2 -= xAxis * xComp + else + line2 -= yAxis * yComp + end + + HighScalabilityLine.InternalLine = line2 + elseif HighScalabilityLine.Dimensions == 3 then + line = HighScalabilityLine.MoreLines[1] + line2 = HighScalabilityLine.MoreLines[2] + line3 = HighScalabilityLine.End - HighScalabilityLine.MorePoints[2] + + -- zero out all components of previous lines + line3 -= line.unit * line.unit:Dot(line3) + line3 -= line2.unit * line2.unit:Dot(line3) + + HighScalabilityLine.InternalLine = line3 + end + + -- resize the "line" graphic to be the correct size and orientation + local tempCFrame = + CFrame.new(HighScalabilityLine.Start, HighScalabilityLine.Start + line) + + if HighScalabilityLine.Dimensions == 1 then -- faster calculation for line + HighScalabilityLine.AdornPart.Size = + Vector3.new(4, 4, line.magnitude + 4) + HighScalabilityLine.AdornPart.CFrame = tempCFrame + + tempCFrame:vectorToWorldSpace( + Vector3.new(2, 2, 2) - HighScalabilityLine.AdornPart.Size / 2 + ) + else + local boxSize = tempCFrame:vectorToObjectSpace(line + line2 + line3) + HighScalabilityLine.AdornPart.Size = Vector3.new(4, 4, 4) + + Vector3.new( + math.abs(boxSize.X), + math.abs(boxSize.Y), + math.abs(boxSize.Z) + ) + HighScalabilityLine.AdornPart.CFrame = tempCFrame + + tempCFrame:vectorToWorldSpace(boxSize / 2) + end + + -- make player able to see this ish + + local gui + if game.Players.LocalPlayer then + gui = game.Players.LocalPlayer:FindFirstChild "PlayerGui" + if + gui + and gui:IsA "PlayerGui" + and ( + (HighScalabilityLine.Dimensions == 1 and line.magnitude > 3) + or HighScalabilityLine.Dimensions > 1 + ) + then -- don't show if mouse hasn't moved enough + HighScalabilityLine.Adorn.Parent = gui + end + end + + if not gui then -- we are in studio + gui = game:GetService "CoreGui" + if + (HighScalabilityLine.Dimensions == 1 and line.magnitude > 3) + or HighScalabilityLine.Dimensions > 1 + then -- don't show if mouse hasn't moved enough + HighScalabilityLine.Adorn.Parent = gui + end + end +end + +local function flashRedBox(stampData: { + CurrentParts: BasePart, + ErrorBox: SelectionBox, +}) + local gui = game.CoreGui + if + game:FindFirstChild "Players" + and game.Players.LocalPlayer + and game.Players.LocalPlayer:FindFirstChild "PlayerGui" + then + gui = game.Players.LocalPlayer.PlayerGui + end + if not stampData.ErrorBox then + return + end + + stampData.ErrorBox.Parent = gui + if stampData.CurrentParts:IsA "Tool" then + stampData.ErrorBox.Adornee = stampData.CurrentParts.Handle + else + stampData.ErrorBox.Adornee = stampData.CurrentParts + end + + delay(0, function() + for _ = 1, 3 do + if stampData.ErrorBox then + stampData.ErrorBox.Visible = true + end + wait(0.13) + if stampData.ErrorBox then + stampData.ErrorBox.Visible = false + end + wait(0.13) + end + if stampData.ErrorBox then + stampData.ErrorBox.Adornee = nil + stampData.ErrorBox.Parent = Tool -- ? + end + end) +end + +local function loadSurfaceTypes(part, surfaces) + part.TopSurface = surfaces[1] + part.BottomSurface = surfaces[2] + part.LeftSurface = surfaces[3] + part.RightSurface = surfaces[4] + part.FrontSurface = surfaces[5] + part.BackSurface = surfaces[6] +end + +local function saveSurfaceTypes(part, myTable) + local tempTable = {} + tempTable[1] = part.TopSurface + tempTable[2] = part.BottomSurface + tempTable[3] = part.LeftSurface + tempTable[4] = part.RightSurface + tempTable[5] = part.FrontSurface + tempTable[6] = part.BackSurface + + myTable[part] = tempTable +end + +local function checkTerrainBlockCollisions( + stampData, + allowedStampRegion, + cellPos, + checkHighScalabilityStamp +) + local cellCenterToWorld = workspace.Terrain.CellCenterToWorld + local cellCenter = + cellCenterToWorld(workspace.Terrain, cellPos.X, cellPos.Y, cellPos.Z) + local cellBlockingParts = workspace:FindPartsInRegion3( + Region3.new( + cellCenter - Vector3.new(2, 2, 2) + insertBoundingBoxOverlapVector, + cellCenter + Vector3.new(2, 2, 2) - insertBoundingBoxOverlapVector + ), + stampData.CurrentParts, + 100 + ) + + local skipThisCell = false + + for b = 1, #cellBlockingParts do + if isBlocker(cellBlockingParts[b]) then + skipThisCell = true + break + end + end + + if not skipThisCell then + -- pop players up above any set cells + local alreadyPushedUp = {} + -- if no blocking model below, then see if stamping on top of a character + for b = 1, #cellBlockingParts do + if + cellBlockingParts[b].Parent + and not alreadyPushedUp[cellBlockingParts[b].Parent] + and cellBlockingParts[b].Parent:FindFirstChild "Humanoid" + and cellBlockingParts[b].Parent + :FindFirstChild("Humanoid") + :IsA "Humanoid" + then + ----------------------------------------------------------------------------------- + local blockingPersonTorso = + cellBlockingParts[b].Parent:FindFirstChild "Torso" + alreadyPushedUp[cellBlockingParts[b].Parent] = true + + if blockingPersonTorso then + -- if so, let's push the person upwards so they pop on top of the stamped model/part (but only if there's space above them) + local newY = cellCenter.Y + 5 + if + spaceAboveCharacter( + blockingPersonTorso, + newY, + stampData + ) + then + blockingPersonTorso.CFrame = blockingPersonTorso.CFrame + + Vector3.new( + 0, + newY - blockingPersonTorso.CFrame.p.Y, + 0 + ) + else + -- if no space, we just skip this one + skipThisCell = true + break + end + end + ----------------------------------------------------------------------------------- + end + end + end + + if not skipThisCell then -- if we STILL aren't skipping... then we're good to go! + local canSetCell = true + + if checkHighScalabilityStamp then -- check to see if cell is in region, if not we'll skip set + if allowedStampRegion then + cellPos = cellCenterToWorld( + workspace.Terrain, + cellPos.X, + cellPos.Y, + cellPos.Z + ) + if + ( + cellPos.X + 2 + > allowedStampRegion.CFrame.p.X + + allowedStampRegion.Size.X / 2 + ) + or (cellPos.X - 2 < allowedStampRegion.CFrame.p.X - allowedStampRegion.Size.X / 2) + or (cellPos.Y + 2 > allowedStampRegion.CFrame.p.Y + allowedStampRegion.Size.Y / 2) + or (cellPos.Y - 2 < allowedStampRegion.CFrame.p.Y - allowedStampRegion.Size.Y / 2) + or (cellPos.Z + 2 > allowedStampRegion.CFrame.p.Z + allowedStampRegion.Size.Z / 2) + or ( + cellPos.Z - 2 + < allowedStampRegion.CFrame.p.Z + - allowedStampRegion.Size.Z / 2 + ) + then + canSetCell = false + end + end + end + + return canSetCell + end + return false +end + +local function ResolveMegaClusterStamp( + stampData: { + CurrentParts: BasePart, + }, + HighScalabilityLine: HighScalabilityLine, + checkHighScalabilityStamp, + allowedStampRegion +) + local cellSet = false + + cluster = workspace.Terrain + + local line = HighScalabilityLine.InternalLine + local cMax = workspace.Terrain.MaxExtents.Max + local cMin = workspace.Terrain.MaxExtents.Min + + local clusterMaterial = 1 -- default is grass + local clusterType = 0 -- default is brick + local clusterOrientation = 0 -- default is 0 rotation + + local autoWedgeClusterParts = false + if stampData.CurrentParts:FindFirstChild "AutoWedge" then + autoWedgeClusterParts = true + end + + if stampData.CurrentParts:FindFirstChild("ClusterMaterial", true) then + clusterMaterial = + stampData.CurrentParts:FindFirstChild("ClusterMaterial", true) + if clusterMaterial:IsA "Vector3Value" then + clusterType = clusterMaterial.Value.Y + clusterOrientation = clusterMaterial.Value.Z + clusterMaterial = clusterMaterial.Value.X + elseif clusterMaterial:IsA "IntValue" then + clusterMaterial = clusterMaterial.Value + end + end + + if + HighScalabilityLine.Adorn.Parent + and HighScalabilityLine.Start + and ( + (HighScalabilityLine.Dimensions > 1) + or (line and line.magnitude > 0) + ) + then + local startCell = + workspace.Terrain:WorldToCell(HighScalabilityLine.Start) + local xInc = { 0, 0, 0 } + local yInc = { 0, 0, 0 } + local zInc = { 0, 0, 0 } + + local incrementVect = { nil, nil, nil } + local stepVect = { + Vector3.new(0, 0, 0), + Vector3.new(0, 0, 0), + Vector3.new(0, 0, 0), + } + + local worldAxes = { + Vector3.new(1, 0, 0), + Vector3.new(0, 1, 0), + Vector3.new(0, 0, 1), + } + + local lines = {} + if HighScalabilityLine.Dimensions > 1 then + table.insert(lines, HighScalabilityLine.MoreLines[1]) + end + if line and line.magnitude > 0 then + table.insert(lines, line) + end + if HighScalabilityLine.Dimensions > 2 then + table.insert(lines, HighScalabilityLine.MoreLines[2]) + end + + for i = 1, #lines do + lines[i] = Vector3.new( + math.floor(lines[i].X + 0.5), + math.floor(lines[i].Y + 0.5), + math.floor(lines[i].Z + 0.5) + ) -- round to integers + + if lines[i].X > 0 then + xInc[i] = 1 + elseif lines[i].X < 0 then + xInc[i] = -1 + end + if lines[i].Y > 0 then + yInc[i] = 1 + elseif lines[i].Y < 0 then + yInc[i] = -1 + end + if lines[i].Z > 0 then + zInc[i] = 1 + elseif lines[i].Z < 0 then + zInc[i] = -1 + end + + incrementVect[i] = Vector3.new(xInc[i], yInc[i], zInc[i]) + if incrementVect[i].magnitude < 0.9 then + incrementVect[i] = nil + end + end + + if not lines[2] then + lines[2] = Vector3.new(0, 0, 0) + end + if not lines[3] then + lines[3] = Vector3.new(0, 0, 0) + end + + local waterForceTag = + stampData.CurrentParts:FindFirstChild("WaterForceTag", true) + local waterForceDirectionTag = stampData.CurrentParts:FindFirstChild( + "WaterForceDirectionTag", + true + ) + + while stepVect[3].magnitude * 4 <= lines[3].magnitude do + local outerStepVectIndex = 1 + while outerStepVectIndex < 4 do + stepVect[2] = Vector3.new(0, 0, 0) + while stepVect[2].magnitude * 4 <= lines[2].magnitude do + local innerStepVectIndex = 1 + while innerStepVectIndex < 4 do + stepVect[1] = Vector3.new(0, 0, 0) + while stepVect[1].magnitude * 4 <= lines[1].magnitude do + local stepVectSum = stepVect[1] + + stepVect[2] + + stepVect[3] + local cellPos = Vector3int16.new( + startCell.X + stepVectSum.X, + startCell.Y + stepVectSum.Y, + startCell.Z + stepVectSum.Z + ) + if + cellPos.X >= cMin.X + and cellPos.Y >= cMin.Y + and cellPos.Z >= cMin.Z + and cellPos.X < cMax.X + and cellPos.Y < cMax.Y + and cellPos.Z < cMax.Z + then + -- check if overlaps player or part + local okToStampTerrainBlock = + checkTerrainBlockCollisions( + stampData, + allowedStampRegion, + cellPos, + checkHighScalabilityStamp + ) + + if okToStampTerrainBlock then + if waterForceTag then + cluster:SetWaterCell( + cellPos.X, + cellPos.Y, + cellPos.Z, + Enum.WaterForce[waterForceTag.Value], + Enum.WaterDirection[waterForceDirectionTag.Value] + ) + else + cluster:SetCell( + cellPos.X, + cellPos.Y, + cellPos.Z, + clusterMaterial, + clusterType, + clusterOrientation + ) + end + cellSet = true + + -- auto-wedge it? + if autoWedgeClusterParts then + workspace.Terrain:AutowedgeCells( + Region3int16.new( + Vector3int16.new( + cellPos.x - 1, + cellPos.y - 1, + cellPos.z - 1 + ), + Vector3int16.new( + cellPos.x + 1, + cellPos.y + 1, + cellPos.z + 1 + ) + ) + ) + end + end + end + stepVect[1] += incrementVect[1] + end + if incrementVect[2] then + while + innerStepVectIndex < 4 + and worldAxes[innerStepVectIndex]:Dot( + incrementVect[2] + ) + == 0 + do + innerStepVectIndex += 1 + end + if innerStepVectIndex < 4 then + stepVect[2] = stepVect[2] + + worldAxes[innerStepVectIndex] + * worldAxes[innerStepVectIndex]:Dot( + incrementVect[2] + ) + end + innerStepVectIndex += 1 + else + stepVect[2] = Vector3.new(1, 0, 0) + innerStepVectIndex = 4 -- skip all remaining loops + end + if stepVect[2].magnitude * 4 > lines[2].magnitude then + innerStepVectIndex = 4 + end + end + end + if incrementVect[3] then + while + outerStepVectIndex < 4 + and worldAxes[outerStepVectIndex]:Dot( + incrementVect[3] + ) + == 0 + do + outerStepVectIndex += 1 + end + if outerStepVectIndex < 4 then + stepVect[3] = stepVect[3] + + worldAxes[outerStepVectIndex] + * worldAxes[outerStepVectIndex]:Dot( + incrementVect[3] + ) + end + outerStepVectIndex += 1 + else -- skip all remaining loops + stepVect[3] = Vector3.new(1, 0, 0) + outerStepVectIndex = 4 + end + if stepVect[3].magnitude * 4 > lines[3].magnitude then + outerStepVectIndex = 4 + end + end + end + end + + -- and also get rid of any HighScalabilityLine stuff if it's there + HighScalabilityLine.Start = nil + HighScalabilityLine.Adorn.Parent = nil + + -- Mark for undo. + if cellSet then + stampData.CurrentParts.Parent = nil + pcall(function() + ChangeHistoryService:SetWaypoint "StamperMulti" + end) + end + + return cellSet +end + function RbxStamper.SetupStamperDragger( - modelToStamp, - Mouse, - StampInModel, + modelToStamp: Model | BasePart, + Mouse: Mouse, + StampInModel: Model?, AllowedStampRegion, - StampFailedFunc + StampFailedFunc: () -> ()? ) if not modelToStamp then - error "SetupStamperDragger: modelToStamp (first arg) is nil! Should be a stamper model" + error "SetupStamperDragger: modelToStamp (first arg) is nil! Should be a stamper model" return nil - end - if not modelToStamp:IsA "Model" and not modelToStamp:IsA "BasePart" then + elseif not modelToStamp:IsA "Model" and not modelToStamp:IsA "BasePart" then error "SetupStamperDragger: modelToStamp (first arg) is neither a Model or Part!" return nil - end - if not Mouse then - error "SetupStamperDragger: Mouse (second arg) is nil! Should be a mouse object" + elseif not Mouse then + error "SetupStamperDragger: Mouse (second arg) is nil! Should be a mouse object" return nil - end - if not Mouse:IsA "Mouse" then + elseif not Mouse:IsA "Mouse" then error "SetupStamperDragger: Mouse (second arg) is not of type Mouse!" return nil end @@ -1023,41 +1628,46 @@ function RbxStamper.SetupStamperDragger( ArchivableTable: {}?, DecalTransparencyTable: {}?, SurfaceTypeTable: {}?, + CurrentParts: BasePart & { + ErrorBox: SelectionBox?, + }, } local mouseTarget - local errorBox = Instance.new "SelectionBox" - errorBox.Color = BrickColor.new "Bright red" - errorBox.Transparency = 0 - errorBox.Archivable = false + local errorBox = New "SelectionBox" { + Color = BrickColor.new "Bright red", + Transparency = 0, + Archivable = false, + } -- for megacluster MEGA STAMPING - local adornPart = Instance.new "Part" - adornPart.Parent = nil - adornPart.formFactor = "Custom" - adornPart.Size = Vector3.new(4, 4, 4) - adornPart.CFrame = CFrame.new() - adornPart.Archivable = false + local adornPart = New "Part" { + formFactor = "Custom", + Size = Vector3.new(4, 4, 4), + CFrame = CFrame.new(), + Archivable = false, + } - local adorn = Instance.new "SelectionBox" - adorn.Color = BrickColor.new "Toothpaste" - adorn.Adornee = adornPart - adorn.Visible = true - adorn.Transparency = 0 - adorn.Name = "HighScalabilityStamperLine" - adorn.Archivable = false + local adorn = New "SelectionBox" { + Color = BrickColor.new "Toothpaste", + Adornee = adornPart, + Visible = true, + Transparency = 0, + Name = "HighScalabilityStamperLine", + Archivable = false, + } - local HighScalabilityLine = {} - HighScalabilityLine.Start = nil - HighScalabilityLine.End = nil - HighScalabilityLine.Adorn = adorn - HighScalabilityLine.AdornPart = adornPart - HighScalabilityLine.InternalLine = nil - HighScalabilityLine.NewHint = true - - HighScalabilityLine.MorePoints = { nil, nil } - HighScalabilityLine.MoreLines = { nil, nil } - HighScalabilityLine.Dimensions = 1 + local HighScalabilityLine: HighScalabilityLine = { + Start = nil, + End = nil, + Adorn = adorn, + AdornPart = adornPart, + InternalLine = nil, + NewHint = true, + MorePoints = { nil, nil }, + MoreLines = { nil, nil }, + Dimensions = 1, + } local control = {} local movingLock = false @@ -1066,182 +1676,27 @@ function RbxStamper.SetupStamperDragger( local mouseCons = {} local keyCon - local stamped = Instance.new "BoolValue" - stamped.Archivable = false - stamped.Value = false + local stamped = New "BoolValue" { + Archivable = false, + Value = false, + } - local lastTarget = {} - lastTarget.TerrainOrientation = 0 - lastTarget.CFrame = 0 + local lastTarget = { + TerrainOrientation = 0, + CFrame = 0, + } - local cellInfo = {} - cellInfo.Material = 1 - cellInfo.clusterType = 0 - cellInfo.clusterOrientation = 0 - - local function isMegaClusterPart() - if not stampData then - return false - end - if not stampData.CurrentParts then - return false - end - - return ( - stampData.CurrentParts:FindFirstChild("ClusterMaterial", true) - or (stampData.CurrentParts.Name == "MegaClusterCube") - ) - end - - local function DoHighScalabilityRegionSelect() - local megaCube = stampData.CurrentParts:FindFirstChild "MegaClusterCube" - if not megaCube then - if stampData.CurrentParts.Name ~= "MegaClusterCube" then - return - else - megaCube = stampData.CurrentParts - end - end - - HighScalabilityLine.End = megaCube.CFrame.p - local line - local line2 = Vector3.new(0, 0, 0) - local line3 = Vector3.new(0, 0, 0) - - if HighScalabilityLine.Dimensions == 1 then - -- extract the line from these positions and limit to a 2D plane made from 2 of the world axes - -- then use dominating axis to limit line to be at 45-degree intervals - -- will use this internal representation of the line for the actual stamping - line = (HighScalabilityLine.End - HighScalabilityLine.Start) - - if math.abs(line.X) < math.abs(line.Y) then - if math.abs(line.X) < math.abs(line.Z) then - -- limit to Y/Z plane, domination unknown - local newY, newZ - if math.abs(line.Y) > math.abs(line.Z) then - newY, newZ = truncateToCircleEighth(line.Y, line.Z) - else - newZ, newY = truncateToCircleEighth(line.Z, line.Y) - end - line = Vector3.new(0, newY, newZ) - else - -- limit to X/Y plane, with Y dominating - local newY, newX = truncateToCircleEighth(line.Y, line.X) - line = Vector3.new(newX, newY, 0) - end - else - if math.abs(line.Y) < math.abs(line.Z) then - -- limit to X/Z plane, domination unknown - local newX, newZ - if math.abs(line.X) > math.abs(line.Z) then - newX, newZ = truncateToCircleEighth(line.X, line.Z) - else - newZ, newX = truncateToCircleEighth(line.Z, line.X) - end - line = Vector3.new(newX, 0, newZ) - else - -- limit to X/Y plane, with X dominating - local newX, newY = truncateToCircleEighth(line.X, line.Y) - line = Vector3.new(newX, newY, 0) - end - end - HighScalabilityLine.InternalLine = line - elseif HighScalabilityLine.Dimensions == 2 then - line = HighScalabilityLine.MoreLines[1] - line2 = HighScalabilityLine.End - HighScalabilityLine.MorePoints[1] - - -- take out any component of line2 along line1, so you get perpendicular to line1 component - line2 -= line.unit * line.unit:Dot(line2) - - local tempCFrame = CFrame.new( - HighScalabilityLine.Start, - HighScalabilityLine.Start + line - ) - - -- then zero out whichever is the smaller component - local yAxis = tempCFrame:vectorToWorldSpace(Vector3.new(0, 1, 0)) - local xAxis = tempCFrame:vectorToWorldSpace(Vector3.new(1, 0, 0)) - - local xComp = xAxis:Dot(line2) - local yComp = yAxis:Dot(line2) - - if math.abs(yComp) > math.abs(xComp) then - line2 -= xAxis * xComp - else - line2 -= yAxis * yComp - end - - HighScalabilityLine.InternalLine = line2 - elseif HighScalabilityLine.Dimensions == 3 then - line = HighScalabilityLine.MoreLines[1] - line2 = HighScalabilityLine.MoreLines[2] - line3 = HighScalabilityLine.End - HighScalabilityLine.MorePoints[2] - - -- zero out all components of previous lines - line3 -= line.unit * line.unit:Dot(line3) - line3 -= line2.unit * line2.unit:Dot(line3) - - HighScalabilityLine.InternalLine = line3 - end - - -- resize the "line" graphic to be the correct size and orientation - local tempCFrame = CFrame.new( - HighScalabilityLine.Start, - HighScalabilityLine.Start + line - ) - - if HighScalabilityLine.Dimensions == 1 then -- faster calculation for line - HighScalabilityLine.AdornPart.Size = - Vector3.new(4, 4, line.magnitude + 4) - HighScalabilityLine.AdornPart.CFrame = tempCFrame - + tempCFrame:vectorToWorldSpace( - Vector3.new(2, 2, 2) - - HighScalabilityLine.AdornPart.Size / 2 - ) - else - local boxSize = tempCFrame:vectorToObjectSpace(line + line2 + line3) - HighScalabilityLine.AdornPart.Size = Vector3.new(4, 4, 4) - + Vector3.new( - math.abs(boxSize.X), - math.abs(boxSize.Y), - math.abs(boxSize.Z) - ) - HighScalabilityLine.AdornPart.CFrame = tempCFrame - + tempCFrame:vectorToWorldSpace(boxSize / 2) - end - - -- make player able to see this ish - - local gui - if game.Players.LocalPlayer then - gui = game.Players.LocalPlayer:FindFirstChild "PlayerGui" - if gui and gui:IsA "PlayerGui" then - if - (HighScalabilityLine.Dimensions == 1 and line.magnitude > 3) - or HighScalabilityLine.Dimensions > 1 - then -- don't show if mouse hasn't moved enough - HighScalabilityLine.Adorn.Parent = gui - end - end - end - - if gui == nil then -- we are in studio - gui = game:GetService "CoreGui" - if - (HighScalabilityLine.Dimensions == 1 and line.magnitude > 3) - or HighScalabilityLine.Dimensions > 1 - then -- don't show if mouse hasn't moved enough - HighScalabilityLine.Adorn.Parent = gui - end - end - end + local cellInfo = { + Material = 1, + clusterType = 0, + clusterOrientation = 0, + } local function DoStamperMouseMove(mouse) if not mouse then error "Error: RbxStamper.DoStamperMouseMove: Mouse is nil" return - end - if not mouse:IsA "Mouse" then + elseif not mouse:IsA "Mouse" then error( `Error: RbxStamper.DoStamperMouseMove: Mouse is of type {mouse.className} should be of type Mouse` ) @@ -1249,14 +1704,7 @@ function RbxStamper.SetupStamperDragger( end -- There wasn't a target (no part or terrain), so check for plane intersection. - if not mouse.Target then - local cellPos = GetTerrainForMouse(mouse) - if not cellPos then - return - end - end - - if not stampData then + if not (mouse.Target or GetTerrainForMouse(mouse)) or not stampData then return end @@ -1334,27 +1782,26 @@ function RbxStamper.SetupStamperDragger( maxBB - insertBoundingBoxOverlapVector ) then - if lastTarget.CFrame then - if + if + lastTarget.CFrame + and stampData.CurrentParts:FindFirstChild( + "ClusterMaterial", + true + ) + then + local theClusterMaterial = stampData.CurrentParts:FindFirstChild( "ClusterMaterial", true ) - then - local theClusterMaterial = + if theClusterMaterial:IsA "Vector3Value" then + local stampClusterMaterial = stampData.CurrentParts:FindFirstChild( "ClusterMaterial", true ) - if theClusterMaterial:IsA "Vector3Value" then - local stampClusterMaterial = - stampData.CurrentParts:FindFirstChild( - "ClusterMaterial", - true - ) - if stampClusterMaterial then - stampClusterMaterial = clusterMat - end + if stampClusterMaterial then + stampClusterMaterial = clusterMat end end end @@ -1362,10 +1809,9 @@ function RbxStamper.SetupStamperDragger( end -- if we are stamping a terrain part, make sure it goes on the grid! Otherwise preview block could be placed off grid, but stamped on grid - if isMegaClusterPart() then - local cellToStamp = - game.Workspace.Terrain:WorldToCell(targetCFrame.p) - local newCFramePosition = game.Workspace.Terrain:CellCenterToWorld( + if isMegaClusterPart(stampData) then + local cellToStamp = workspace.Terrain:WorldToCell(targetCFrame.p) + local newCFramePosition = workspace.Terrain:CellCenterToWorld( cellToStamp.X, cellToStamp.Y, cellToStamp.Z @@ -1426,7 +1872,7 @@ function RbxStamper.SetupStamperDragger( if modelInfo then hitFace = modelTargetSurface( modelInfo.Parent, - game.Workspace.CurrentCamera.CoordinateFrame.p, + workspace.CurrentCamera.CoordinateFrame.p, mouse.Hit.p ) end @@ -1445,7 +1891,7 @@ function RbxStamper.SetupStamperDragger( hitFace = modelTargetSurface( stampData.CurrentParts, mouse.Hit.p, - game.Workspace.CurrentCamera.CoordinateFrame.p + workspace.CurrentCamera.CoordinateFrame.p ) -- are we stamping WITH an unstampable surface? @@ -1467,20 +1913,12 @@ function RbxStamper.SetupStamperDragger( game.JointsService:SetJoinAfterMoveInstance(stampData.CurrentParts) -- most common mouse inactive error occurs here, so check mouse active one more time in a pcall - if - not pcall(function() - if - mouse - and mouse.Target - and mouse.Target.Parent:FindFirstChild "RobloxModel" - == nil - then - return - else - return - end - end) - then + local ok = pcall(function() + return mouse -- ? - Heliodex + and mouse.Target + and not mouse.Target.Parent:FindFirstChild "RobloxModel" + end) + if not ok then game.JointsService:ClearJoinAfterMoveJoints() mouse = nil error "Error: RbxStamper.DoStamperMouseMove Mouse is nil on second check" @@ -1500,11 +1938,11 @@ function RbxStamper.SetupStamperDragger( -- here we allow for a line of high-scalability parts if - isMegaClusterPart() + isMegaClusterPart(stampData) and HighScalabilityLine and HighScalabilityLine.Start then - DoHighScalabilityRegionSelect() + DoHighScalabilityRegionSelect(stampData, HighScalabilityLine) end end @@ -1553,20 +1991,18 @@ function RbxStamper.SetupStamperDragger( -- update everything else in MouseMove DoStamperMouseMove(mouse) end - elseif key == "c" then -- try to expand our high scalability dragger dimension - if + elseif + key == "c" + and HighScalabilityLine.InternalLine + and HighScalabilityLine.InternalLine.magnitude > 0 + and HighScalabilityLine.Dimensions < 3 + then -- try to expand our high scalability dragger dimension + HighScalabilityLine.MorePoints[HighScalabilityLine.Dimensions] = + HighScalabilityLine.End + HighScalabilityLine.MoreLines[HighScalabilityLine.Dimensions] = HighScalabilityLine.InternalLine - and HighScalabilityLine.InternalLine.magnitude > 0 - and HighScalabilityLine.Dimensions < 3 - then - HighScalabilityLine.MorePoints[HighScalabilityLine.Dimensions] = - HighScalabilityLine.End - HighScalabilityLine.MoreLines[HighScalabilityLine.Dimensions] = - HighScalabilityLine.InternalLine - HighScalabilityLine.Dimensions = HighScalabilityLine.Dimensions - + 1 - HighScalabilityLine.NewHint = true - end + HighScalabilityLine.Dimensions = HighScalabilityLine.Dimensions + 1 + HighScalabilityLine.NewHint = true end end @@ -1577,50 +2013,13 @@ function RbxStamper.SetupStamperDragger( ) local function resetHighScalabilityLine() - if HighScalabilityLine then - HighScalabilityLine.Start = nil - HighScalabilityLine.End = nil - HighScalabilityLine.InternalLine = nil - HighScalabilityLine.NewHint = true - end - end - - local function flashRedBox() - local gui = game.CoreGui - if - game:FindFirstChild "Players" - and game.Players.LocalPlayer - and game.Players.LocalPlayer:FindFirstChild "PlayerGui" - then - gui = game.Players.LocalPlayer.PlayerGui - end - if not stampData.ErrorBox then + if not HighScalabilityLine then return end - - stampData.ErrorBox.Parent = gui - if stampData.CurrentParts:IsA "Tool" then - stampData.ErrorBox.Adornee = stampData.CurrentParts.Handle - else - stampData.ErrorBox.Adornee = stampData.CurrentParts - end - - delay(0, function() - for _ = 1, 3 do - if stampData.ErrorBox then - stampData.ErrorBox.Visible = true - end - wait(0.13) - if stampData.ErrorBox then - stampData.ErrorBox.Visible = false - end - wait(0.13) - end - if stampData.ErrorBox then - stampData.ErrorBox.Adornee = nil - stampData.ErrorBox.Parent = Tool -- ? - end - end) + HighScalabilityLine.Start = nil + HighScalabilityLine.End = nil + HighScalabilityLine.InternalLine = nil + HighScalabilityLine.NewHint = true end local function DoStamperMouseDown(mouse) @@ -1635,7 +2034,7 @@ function RbxStamper.SetupStamperDragger( elseif not ( stampData - and isMegaClusterPart() + and isMegaClusterPart(stampData) and mouse and HighScalabilityLine ) @@ -1645,7 +2044,7 @@ function RbxStamper.SetupStamperDragger( local megaCube = stampData.CurrentParts:FindFirstChild("MegaClusterCube", true) - local terrain = game.Workspace.Terrain + local terrain = workspace.Terrain if megaCube then HighScalabilityLine.Dimensions = 1 local tempCell = terrain:WorldToCell(megaCube.CFrame.p) @@ -1662,27 +2061,6 @@ function RbxStamper.SetupStamperDragger( end end - local function loadSurfaceTypes(part, surfaces) - part.TopSurface = surfaces[1] - part.BottomSurface = surfaces[2] - part.LeftSurface = surfaces[3] - part.RightSurface = surfaces[4] - part.FrontSurface = surfaces[5] - part.BackSurface = surfaces[6] - end - - local function saveSurfaceTypes(part, myTable) - local tempTable = {} - tempTable[1] = part.TopSurface - tempTable[2] = part.BottomSurface - tempTable[3] = part.LeftSurface - tempTable[4] = part.RightSurface - tempTable[5] = part.FrontSurface - tempTable[6] = part.BackSurface - - myTable[part] = tempTable - end - -- local function makeSurfaceUnjoinable(part, surface) -- -- TODO: FILL OUT! -- end @@ -1768,15 +2146,15 @@ function RbxStamper.SetupStamperDragger( wait(0.03) currTime = tick() end - if part and part:IsA "BasePart" then - if - stampData.TransparencyTable - and stampData.TransparencyTable[part] - then - part.Transparency = gDesiredTrans - + (1 - gDesiredTrans) - * stampData.TransparencyTable[part] - end + if + part + and part:IsA "BasePart" + and stampData.TransparencyTable + and stampData.TransparencyTable[part] + then + part.Transparency = gDesiredTrans + + (1 - gDesiredTrans) + * stampData.TransparencyTable[part] end end) end @@ -1841,382 +2219,6 @@ function RbxStamper.SetupStamperDragger( return clone, parts end - local function checkTerrainBlockCollisions( - cellPos, - checkHighScalabilityStamp - ) - local cellCenterToWorld = game.Workspace.Terrain.CellCenterToWorld - local cellCenter = cellCenterToWorld( - game.Workspace.Terrain, - cellPos.X, - cellPos.Y, - cellPos.Z - ) - local cellBlockingParts = game.Workspace:FindPartsInRegion3( - Region3.new( - cellCenter - - Vector3.new(2, 2, 2) - + insertBoundingBoxOverlapVector, - cellCenter - + Vector3.new(2, 2, 2) - - insertBoundingBoxOverlapVector - ), - stampData.CurrentParts, - 100 - ) - - local skipThisCell = false - - for b = 1, #cellBlockingParts do - if isBlocker(cellBlockingParts[b]) then - skipThisCell = true - break - end - end - - if not skipThisCell then - -- pop players up above any set cells - local alreadyPushedUp = {} - -- if no blocking model below, then see if stamping on top of a character - for b = 1, #cellBlockingParts do - if - cellBlockingParts[b].Parent - and not alreadyPushedUp[cellBlockingParts[b].Parent] - and cellBlockingParts[b].Parent:FindFirstChild "Humanoid" - and cellBlockingParts[b].Parent - :FindFirstChild("Humanoid") - :IsA "Humanoid" - then - ----------------------------------------------------------------------------------- - local blockingPersonTorso = - cellBlockingParts[b].Parent:FindFirstChild "Torso" - alreadyPushedUp[cellBlockingParts[b].Parent] = true - - if blockingPersonTorso then - -- if so, let's push the person upwards so they pop on top of the stamped model/part (but only if there's space above them) - local newY = cellCenter.Y + 5 - if - spaceAboveCharacter( - blockingPersonTorso, - newY, - stampData - ) - then - blockingPersonTorso.CFrame = blockingPersonTorso.CFrame - + Vector3.new( - 0, - newY - blockingPersonTorso.CFrame.p.Y, - 0 - ) - else - -- if no space, we just skip this one - skipThisCell = true - break - end - end - ----------------------------------------------------------------------------------- - end - end - end - - if not skipThisCell then -- if we STILL aren't skipping... then we're good to go! - local canSetCell = true - - if checkHighScalabilityStamp then -- check to see if cell is in region, if not we'll skip set - if allowedStampRegion then - cellPos = cellCenterToWorld( - game.Workspace.Terrain, - cellPos.X, - cellPos.Y, - cellPos.Z - ) - if - ( - cellPos.X + 2 - > allowedStampRegion.CFrame.p.X - + allowedStampRegion.Size.X / 2 - ) - or (cellPos.X - 2 < allowedStampRegion.CFrame.p.X - allowedStampRegion.Size.X / 2) - or (cellPos.Y + 2 > allowedStampRegion.CFrame.p.Y + allowedStampRegion.Size.Y / 2) - or (cellPos.Y - 2 < allowedStampRegion.CFrame.p.Y - allowedStampRegion.Size.Y / 2) - or (cellPos.Z + 2 > allowedStampRegion.CFrame.p.Z + allowedStampRegion.Size.Z / 2) - or ( - cellPos.Z - 2 - < allowedStampRegion.CFrame.p.Z - - allowedStampRegion.Size.Z / 2 - ) - then - canSetCell = false - end - end - end - - return canSetCell - end - return false - end - - local function ResolveMegaClusterStamp(checkHighScalabilityStamp) - local cellSet = false - - cluster = game.Workspace.Terrain - - local line = HighScalabilityLine.InternalLine - local cMax = game.Workspace.Terrain.MaxExtents.Max - local cMin = game.Workspace.Terrain.MaxExtents.Min - - local clusterMaterial = 1 -- default is grass - local clusterType = 0 -- default is brick - local clusterOrientation = 0 -- default is 0 rotation - - local autoWedgeClusterParts = false - if stampData.CurrentParts:FindFirstChild "AutoWedge" then - autoWedgeClusterParts = true - end - - if stampData.CurrentParts:FindFirstChild("ClusterMaterial", true) then - clusterMaterial = - stampData.CurrentParts:FindFirstChild("ClusterMaterial", true) - if clusterMaterial:IsA "Vector3Value" then - clusterType = clusterMaterial.Value.Y - clusterOrientation = clusterMaterial.Value.Z - clusterMaterial = clusterMaterial.Value.X - elseif clusterMaterial:IsA "IntValue" then - clusterMaterial = clusterMaterial.Value - end - end - - if - HighScalabilityLine.Adorn.Parent - and HighScalabilityLine.Start - and ( - (HighScalabilityLine.Dimensions > 1) - or (line and line.magnitude > 0) - ) - then - local startCell = - game.Workspace.Terrain:WorldToCell(HighScalabilityLine.Start) - local xInc = { 0, 0, 0 } - local yInc = { 0, 0, 0 } - local zInc = { 0, 0, 0 } - - local incrementVect = { nil, nil, nil } - local stepVect = { - Vector3.new(0, 0, 0), - Vector3.new(0, 0, 0), - Vector3.new(0, 0, 0), - } - - local worldAxes = { - Vector3.new(1, 0, 0), - Vector3.new(0, 1, 0), - Vector3.new(0, 0, 1), - } - - local lines = {} - if HighScalabilityLine.Dimensions > 1 then - table.insert(lines, HighScalabilityLine.MoreLines[1]) - end - if line and line.magnitude > 0 then - table.insert(lines, line) - end - if HighScalabilityLine.Dimensions > 2 then - table.insert(lines, HighScalabilityLine.MoreLines[2]) - end - - for i = 1, #lines do - lines[i] = Vector3.new( - math.floor(lines[i].X + 0.5), - math.floor(lines[i].Y + 0.5), - math.floor(lines[i].Z + 0.5) - ) -- round to integers - - if lines[i].X > 0 then - xInc[i] = 1 - elseif lines[i].X < 0 then - xInc[i] = -1 - end - if lines[i].Y > 0 then - yInc[i] = 1 - elseif lines[i].Y < 0 then - yInc[i] = -1 - end - if lines[i].Z > 0 then - zInc[i] = 1 - elseif lines[i].Z < 0 then - zInc[i] = -1 - end - - incrementVect[i] = Vector3.new(xInc[i], yInc[i], zInc[i]) - if incrementVect[i].magnitude < 0.9 then - incrementVect[i] = nil - end - end - - if not lines[2] then - lines[2] = Vector3.new(0, 0, 0) - end - if not lines[3] then - lines[3] = Vector3.new(0, 0, 0) - end - - local waterForceTag = - stampData.CurrentParts:FindFirstChild("WaterForceTag", true) - local waterForceDirectionTag = - stampData.CurrentParts:FindFirstChild( - "WaterForceDirectionTag", - true - ) - - while stepVect[3].magnitude * 4 <= lines[3].magnitude do - local outerStepVectIndex = 1 - while outerStepVectIndex < 4 do - stepVect[2] = Vector3.new(0, 0, 0) - while stepVect[2].magnitude * 4 <= lines[2].magnitude do - local innerStepVectIndex = 1 - while innerStepVectIndex < 4 do - stepVect[1] = Vector3.new(0, 0, 0) - while - stepVect[1].magnitude * 4 <= lines[1].magnitude - do - local stepVectSum = stepVect[1] - + stepVect[2] - + stepVect[3] - local cellPos = Vector3int16.new( - startCell.X + stepVectSum.X, - startCell.Y + stepVectSum.Y, - startCell.Z + stepVectSum.Z - ) - if - cellPos.X >= cMin.X - and cellPos.Y >= cMin.Y - and cellPos.Z >= cMin.Z - and cellPos.X < cMax.X - and cellPos.Y < cMax.Y - and cellPos.Z < cMax.Z - then - -- check if overlaps player or part - local okToStampTerrainBlock = - checkTerrainBlockCollisions( - cellPos, - checkHighScalabilityStamp - ) - - if okToStampTerrainBlock then - if waterForceTag then - cluster:SetWaterCell( - cellPos.X, - cellPos.Y, - cellPos.Z, - Enum.WaterForce[waterForceTag.Value], - Enum.WaterDirection[waterForceDirectionTag.Value] - ) - else - cluster:SetCell( - cellPos.X, - cellPos.Y, - cellPos.Z, - clusterMaterial, - clusterType, - clusterOrientation - ) - end - cellSet = true - - -- auto-wedge it? - if autoWedgeClusterParts then - game.Workspace.Terrain:AutowedgeCells( - Region3int16.new( - Vector3int16.new( - cellPos.x - 1, - cellPos.y - 1, - cellPos.z - 1 - ), - Vector3int16.new( - cellPos.x + 1, - cellPos.y + 1, - cellPos.z + 1 - ) - ) - ) - end - end - end - stepVect[1] += incrementVect[1] - end - if incrementVect[2] then - while - innerStepVectIndex < 4 - and worldAxes[innerStepVectIndex]:Dot( - incrementVect[2] - ) - == 0 - do - innerStepVectIndex += 1 - end - if innerStepVectIndex < 4 then - stepVect[2] = stepVect[2] - + worldAxes[innerStepVectIndex] - * worldAxes[innerStepVectIndex]:Dot( - incrementVect[2] - ) - end - innerStepVectIndex += 1 - else - stepVect[2] = Vector3.new(1, 0, 0) - innerStepVectIndex = 4 -- skip all remaining loops - end - if - stepVect[2].magnitude * 4 > lines[2].magnitude - then - innerStepVectIndex = 4 - end - end - end - if incrementVect[3] then - while - outerStepVectIndex < 4 - and worldAxes[outerStepVectIndex]:Dot( - incrementVect[3] - ) - == 0 - do - outerStepVectIndex += 1 - end - if outerStepVectIndex < 4 then - stepVect[3] = stepVect[3] - + worldAxes[outerStepVectIndex] - * worldAxes[outerStepVectIndex]:Dot( - incrementVect[3] - ) - end - outerStepVectIndex += 1 - else -- skip all remaining loops - stepVect[3] = Vector3.new(1, 0, 0) - outerStepVectIndex = 4 - end - if stepVect[3].magnitude * 4 > lines[3].magnitude then - outerStepVectIndex = 4 - end - end - end - end - - -- and also get rid of any HighScalabilityLine stuff if it's there - HighScalabilityLine.Start = nil - HighScalabilityLine.Adorn.Parent = nil - - -- Mark for undo. - if cellSet then - stampData.CurrentParts.Parent = nil - pcall(function() - ChangeHistoryService:SetWaypoint "StamperMulti" - end) - end - - return cellSet - end - local function DoStamperMouseUp(mouse) if not mouse then error "Error: RbxStamper.DoStamperMouseUp: Mouse is nil" @@ -2241,7 +2243,7 @@ function RbxStamper.SetupStamperDragger( local checkHighScalabilityStamp if stampInModel then local canStamp - local isHSLPart = isMegaClusterPart() + local isHSLPart = isMegaClusterPart(stampData) if isHSLPart @@ -2269,7 +2271,7 @@ function RbxStamper.SetupStamperDragger( -- if unstampable face, then don't let us stamp there! if unstampableSurface then - flashRedBox() + flashRedBox(stampData) return false end @@ -2301,11 +2303,11 @@ function RbxStamper.SetupStamperDragger( maxBB - insertBoundingBoxOverlapVector ) then - flashRedBox() + flashRedBox(stampData) return false end - local blockingParts = game.Workspace:FindPartsInRegion3( + local blockingParts = workspace:FindPartsInRegion3( Region3.new( minBB + insertBoundingBoxOverlapVector, maxBB - insertBoundingBoxOverlapVector @@ -2316,7 +2318,7 @@ function RbxStamper.SetupStamperDragger( for b = 1, #blockingParts do if isBlocker(blockingParts[b]) then - flashRedBox() + flashRedBox(stampData) return false end end @@ -2355,7 +2357,7 @@ function RbxStamper.SetupStamperDragger( ) else -- if no space, we just error - flashRedBox() + flashRedBox(stampData) return false end end @@ -2373,15 +2375,15 @@ function RbxStamper.SetupStamperDragger( end -- something will be stamped! so set the "StampedSomething" toggle to true - if game:FindFirstChild "Players" then - if game.Players.LocalPlayer then - if game.Players.LocalPlayer.Character then - local localChar = game.Players.LocalPlayer.Character - local stampTracker = localChar:FindFirstChild "StampTracker" - if stampTracker and not stampTracker.Value then - stampTracker.Value = true - end - end + if + game:FindFirstChild "Players" + and game.Players.LocalPlayer + and game.Players.LocalPlayer.Character + then + local stampTracker = + game.Players.LocalPlayer.Character:FindFirstChild "StampTracker" + if stampTracker and not stampTracker.Value then + stampTracker.Value = true end end @@ -2389,26 +2391,29 @@ function RbxStamper.SetupStamperDragger( if HighScalabilityLine.Start and HighScalabilityLine.Adorn.Parent - and isMegaClusterPart() + and isMegaClusterPart(stampData) + and ( + ResolveMegaClusterStamp( + stampData, + HighScalabilityLine, + checkHighScalabilityStamp, + allowedStampRegion + ) or checkHighScalabilityStamp + ) then - if - ResolveMegaClusterStamp(checkHighScalabilityStamp) - or checkHighScalabilityStamp - then - -- kill the ghost part - stampData.CurrentParts.Parent = nil - return true - end + -- kill the ghost part + stampData.CurrentParts.Parent = nil + return true end -- not High-Scalability-Line-Based, so behave normally [and get rid of any HSL stuff] HighScalabilityLine.Start = nil HighScalabilityLine.Adorn.Parent = nil - cluster = game.Workspace.Terrain + cluster = workspace.Terrain -- if target point is in cluster, just use cluster:SetCell - if isMegaClusterPart() then + if isMegaClusterPart(stampData) then -- if targetCFrame is inside cluster, just set that cell to 1 and return --local cellPos = cluster:WorldToCell(targetCFrame.p) @@ -2421,10 +2426,17 @@ function RbxStamper.SetupStamperDragger( cellPos = cluster:WorldToCell(stampData.CurrentParts.CFrame.p) end - local cMax = game.Workspace.Terrain.MaxExtents.Max - local cMin = game.Workspace.Terrain.MaxExtents.Min + local cMax = workspace.Terrain.MaxExtents.Max + local cMin = workspace.Terrain.MaxExtents.Min - if checkTerrainBlockCollisions(cellPos, false) then + if + checkTerrainBlockCollisions( + stampData, + allowedStampRegion, + cellPos, + false + ) + then local clusterValues = stampData.CurrentParts:FindFirstChild( "ClusterMaterial", true @@ -2489,7 +2501,7 @@ function RbxStamper.SetupStamperDragger( -- auto-wedge it if autoWedgeClusterParts then - game.Workspace.Terrain:AutowedgeCells( + workspace.Terrain:AutowedgeCells( Region3int16.new( Vector3int16.new( cellPos.x - 1, @@ -2516,16 +2528,14 @@ function RbxStamper.SetupStamperDragger( end else -- you tried to stamp a HSL-single part where one does not belong! - flashRedBox() + flashRedBox(stampData) return false end end local function getPlayer() - if game:FindFirstChild "Players" then - if game.Players.LocalPlayer then - return game.Players.LocalPlayer - end + if game:FindFirstChild "Players" and game.Players.LocalPlayer then + return game.Players.LocalPlayer end return nil end @@ -2556,45 +2566,46 @@ function RbxStamper.SetupStamperDragger( stampData.CurrentParts:FindFirstChild "PlayerNameTag" local tempPlayerValue - if playerIdTag ~= nil then + if playerIdTag then tempPlayerValue = getPlayer() - if tempPlayerValue ~= nil then + if tempPlayerValue then playerIdTag.Value = tempPlayerValue.userId end end - if playerNameTag ~= nil then - if - game:FindFirstChild "Players" - and game.Players.LocalPlayer - then - tempPlayerValue = game.Players.LocalPlayer - if tempPlayerValue ~= nil then - playerNameTag.Value = tempPlayerValue.Name - end + if + playerNameTag + and game:FindFirstChild "Players" + and game.Players.LocalPlayer + then + tempPlayerValue = game.Players.LocalPlayer + if tempPlayerValue then + playerNameTag.Value = tempPlayerValue.Name end end -- ...and tag all inserted models for subsequent origin identification -- if no RobloxModel tag already exists, then add it. - if stampData.CurrentParts:FindFirstChild "RobloxModel" == nil then - local stringTag = Instance.new "BoolValue" - stringTag.Name = "RobloxModel" - stringTag.Parent = stampData.CurrentParts + if not stampData.CurrentParts:FindFirstChild "RobloxModel" then + New "BoolValue" { + Name = "RobloxModel", + Parent = stampData.CurrentParts, + } if - stampData.CurrentParts:FindFirstChild "RobloxStamper" - == nil + not stampData.CurrentParts:FindFirstChild "RobloxStamper" then - local stringTag2 = Instance.new "BoolValue" - stringTag2.Name = "RobloxStamper" - stringTag2.Parent = stampData.CurrentParts + New "BoolValue" { + Name = "RobloxStamper", + Parent = stampData.CurrentParts, + } end end else stampData.CurrentParts:BreakJoints() if stampData.CurrentParts:FindFirstChild "RobloxStamper" == nil then - local stringTag2 = Instance.new "BoolValue" - stringTag2.Name = "RobloxStamper" - stringTag2.Parent = stampData.CurrentParts + New "BoolValue" { + Name = "RobloxStamper", + Parent = stampData.CurrentParts, + } end end @@ -2627,7 +2638,7 @@ function RbxStamper.SetupStamperDragger( loadSurfaceTypes(part, surfaces) end - if isMegaClusterPart() then + if isMegaClusterPart(stampData) then stampData.CurrentParts.Transparency = 0 end @@ -2654,12 +2665,12 @@ function RbxStamper.SetupStamperDragger( -- ghostRemovalScript.Parent = nil -- end - --Re-enable the scripts + -- Re-enable the scripts for _, script in pairs(stampData.DisabledScripts) do script.Disabled = false end - --Now that they are all marked enabled, reinsert them into the world so they start running + -- Now that they are all marked enabled, reinsert them into the world so they start running for _, script in pairs(stampData.DisabledScripts) do local oldParent = script.Parent script.Parent = nil @@ -2782,11 +2793,7 @@ function RbxStamper.SetupStamperDragger( end stampData.ErrorBox = errorBox - if stampInModel then - clone.Parent = stampInModel - else - clone.Parent = game.Workspace - end + clone.Parent = stampInModel or workspace if clone:FindFirstChild("ClusterMaterial", true) then -- extract all info from vector local clusterMaterial = @@ -2972,13 +2979,15 @@ function RbxStamper.Help(funcNameOrFunc) funcNameOrFunc == "GetStampModel" or funcNameOrFunc == RbxStamper.GetStampModel then - return "Function GetStampModel. Arguments: assetId, useAssetVersionId. assetId is the asset to load in, define useAssetVersionId as true if assetId is a version id instead of a relative assetId. Side effect: returns a model of the assetId, or a string with error message if something fails" - end - if + return [[Function GetStampModel. +Arguments: assetId, useAssetVersionId. assetId is the asset to load in, define useAssetVersionId as true if assetId is a version id instead of a relative assetId. Side effect: returns a model of the assetId, or a string with error message if something fails]] + elseif funcNameOrFunc == "SetupStamperDragger" or funcNameOrFunc == RbxStamper.SetupStamperDragger then - return "Function SetupStamperDragger. Side Effect: Creates 4x4 stamping mechanism for building out parts quickly. Arguments: ModelToStamp, Mouse, LegalStampCheckFunction. ModelToStamp should be a Model or Part, preferrably loaded from RbxStamper.GetStampModel and should have extents that are multiples of 4. Mouse should be a mouse object (obtained from things such as Tool.OnEquipped), used to drag parts around 'stamp' them out. LegalStampCheckFunction is optional, used as a callback with a table argument (table is full of instances about to be stamped). Function should return either true or false, false stopping the stamp action." + return [[Function SetupStamperDragger. +Side Effect: Creates 4x4 stamping mechanism for building out parts quickly. +Arguments: ModelToStamp, Mouse, LegalStampCheckFunction. ModelToStamp should be a Model or Part, preferrably loaded from RbxStamper.GetStampModel and should have extents that are multiples of 4. Mouse should be a mouse object (obtained from things such as Tool.OnEquipped), used to drag parts around 'stamp' them out. LegalStampCheckFunction is optional, used as a callback with a table argument (table is full of instances about to be stamped). Function should return either true or false, false stopping the stamp action.]] end return "No help available for this function" end diff --git a/luau/89449008.luau b/luau/89449008.luau index ba4b367..efe01e9 100644 --- a/luau/89449008.luau +++ b/luau/89449008.luau @@ -1,4 +1,4 @@ --- CoreGui.MercuryGui.Backpack.CoreScripts/BackpackScripts/Back (1?) +-- CoreGui.RobloxGui.Backpack.CoreScripts/BackpackScripts/Back (1?) print "[Mercury]: Loaded corescript 89449008" local UserInputService = game:GetService "UserInputService" diff --git a/luau/89449093.luau b/luau/89449093.luau index c6bab00..f57c280 100644 --- a/luau/89449093.luau +++ b/luau/89449093.luau @@ -1,4 +1,4 @@ --- CoreGui.MercuryGui.Backpack.CoreScripts/BackpackScripts/Back (2?) +-- CoreGui.RobloxGui.Backpack.CoreScripts/BackpackScripts/Back (2?) print "[Mercury]: Loaded corescript 89449093" local News = require "../Modules/New" @@ -53,7 +53,7 @@ local searchBox = waitForChild(backpack.SearchFrame.SearchBoxFrame, "SearchBox") local searchButton = waitForChild(backpack.SearchFrame, "SearchButton") local resetButton = waitForChild(backpack.SearchFrame, "ResetButton") -local mercuryGui = waitForChild(game.CoreGui, "MercuryGui") +local mercuryGui = waitForChild(game.CoreGui, "RobloxGui") local currentLoadout = waitForChild(mercuryGui, "CurrentLoadout") local loadoutBackground = waitForChild(currentLoadout, "Background") diff --git a/luau/97188756.luau b/luau/97188756.luau index d391e7b..4130b3b 100644 --- a/luau/97188756.luau +++ b/luau/97188756.luau @@ -1,5 +1,5 @@ --!strict --- CoreGui.MercuryGui.CoreScripts/ChatScript +-- CoreGui.RobloxGui.CoreScripts/ChatScript print "[Mercury]: Loaded corescript 97188756" local RunService = game:GetService "RunService" @@ -25,7 +25,7 @@ local Player = game.Players.LocalPlayer while not Player.Character do RunService.Heartbeat:wait() end -local Camera = game.Workspace.CurrentCamera +local Camera = workspace.CurrentCamera -- Services local CoreGui = game:GetService "CoreGui" @@ -653,7 +653,7 @@ end -- Create the initial Chat stuff -- Done only once function Chat:CreateGui() - self.Gui = WaitForChild(CoreGui, "MercuryGui") + self.Gui = WaitForChild(CoreGui, "RobloxGui") self.Frame = New "Frame" { Name = "ChatFrame", --Size = self.Configuration.Size; @@ -706,35 +706,37 @@ function Chat:CreateGui() end) end - if forceChatGUI or Player.ChatMode == Enum.ChatMode.TextAndMenu then - Chat:CreateChatBar() - - if self.ChatBar then - self.ChatBar.FocusLost:connect(function(enterPressed) - Chat.GotFocus = false - 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(Players.TeamChat, Players, cText) - else - pcall(Players.Chat, Players, cText) - end - - if self.ClickToChatButton then - self.ClickToChatButton.Visible = true - end - self.ChatBar.Text = "" - end - Spawn(function() - wait(5) - if not Chat.GotFocus then - Chat.Frame.Background.Visible = false - end - end) - end) - end + if not (forceChatGUI or Player.ChatMode == Enum.ChatMode.TextAndMenu) then + return end + Chat:CreateChatBar() + if not self.ChatBar then + return + end + + self.ChatBar.FocusLost:connect(function(enterPressed) + Chat.GotFocus = false + 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(Players.TeamChat, Players, cText) + else + pcall(Players.Chat, Players, cText) + end + + if self.ClickToChatButton then + self.ClickToChatButton.Visible = true + end + self.ChatBar.Text = "" + end + Spawn(function() + wait(5) + if not Chat.GotFocus then + Chat.Frame.Background.Visible = false + end + end) + end) end -- Scrolling function @@ -754,7 +756,7 @@ function Input:OnMouseScroll() wait(0.25) end end - wait() + wait(0.03) end end) if Chat:CheckIfInBounds(Input.Speed) then diff --git a/luau/join.luau b/luau/join.luau index a706080..4e5bf4e 100644 --- a/luau/join.luau +++ b/luau/join.luau @@ -4,9 +4,6 @@ print "[Mercury]: Loaded Join corescript" local InsertService = game:GetService "InsertService" local ChangeHistoryService = game:GetService "ChangeHistoryService" local ContentProvider = game:GetService "ContentProvider" -local SocialService = game:GetService "SocialService" -local GamePassService = game:GetService "GamePassService" -local MarketplaceService = game:GetService "MarketplaceService" local Players = game:GetService "Players" local Client = game:GetService "NetworkClient" local Visit = game:GetService "Visit" @@ -53,30 +50,6 @@ InsertService:SetCollectionUrl "http://banland.xyz/game/tools/insertasset?sid=%d InsertService:SetAssetUrl "http://banland.xyz/asset?id=%d" InsertService:SetAssetVersionUrl "http://banland.xyz/asset?assetversionid=%d" -pcall(function() - SocialService:SetFriendUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsFriendsWith&playerid=%d&userid=%d" -end) -pcall(function() - SocialService:SetBestFriendUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsBestFriendsWith&playerid=%d&userid=%d" -end) -pcall(function() - SocialService:SetGroupUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsInGroup&playerid=%d&groupid=%d" -end) -pcall(function() - SocialService:SetGroupRankUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRank&playerid=%d&groupid=%d" -end) -pcall(function() - SocialService:SetGroupRoleUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRole&playerid=%d&groupid=%d" -end) -pcall(function() - GamePassService:SetPlayerHasPassUrl "http://banland.xyz/Game/GamePass/GamePassHandler.ashx?Action=HasPass&UserID=%d&PassID=%d" -end) -pcall(function() - MarketplaceService:SetProductInfoUrl "http://banland.xyz/marketplace/productinfo?assetId=%d" -end) -pcall(function() - MarketplaceService:SetPlayerOwnsAssetUrl "http://banland.xyz/ownership/hasasset?userId=%d&assetId=%d" -end) pcall(function() game:SetCreatorID(_CREATOR_ID, Enum.CreatorType.User) end) diff --git a/luau/studio.luau b/luau/studio.luau index 503de9f..a35a78d 100644 --- a/luau/studio.luau +++ b/luau/studio.luau @@ -1,13 +1,10 @@ --!strict print "[Mercury]: Loaded Studio corescript" --- local MarketplaceService = game:GetService "MarketplaceService" local InsertService = game:GetService "InsertService" --- local SocialService = game:GetService "SocialService" --- local GamePassService = game:GetService "GamePassService" local ScriptInformationProvider = game:GetService "ScriptInformationProvider" local ScriptContext = game:GetService "ScriptContext" --- Setup studio cmd bar & load core scripts + pcall(function() InsertService:SetFreeModelUrl "http://banland.xyz/game/tools/insertasset?type=fm&q=%s&pg=%d&rs=%d" end) @@ -23,38 +20,9 @@ InsertService:SetAssetUrl "http://banland.xyz/asset?id=%d" InsertService:SetAssetVersionUrl "http://banland.xyz/asset/?assetversionid=%d" InsertService:SetTrustLevel(0) --- pcall(function() --- SocialService:SetFriendUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsFriendsWith&playerid=%d&userid=%d" --- end) --- pcall(function() --- SocialService:SetBestFriendUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsBestFriendsWith&playerid=%d&userid=%d" --- end) --- pcall(function() --- SocialService:SetGroupUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsInGroup&playerid=%d&groupid=%d" --- end) --- pcall(function() --- SocialService:SetGroupRankUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRank&playerid=%d&groupid=%d" --- end) --- pcall(function() --- SocialService:SetGroupRoleUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRole&playerid=%d&groupid=%d" --- end) --- pcall(function() --- GamePassService:SetPlayerHasPassUrl "http://banland.xyz/Game/GamePass/GamePassHandler.ashx?Action=HasPass&UserID=%d&PassID=%d" --- end) --- pcall(function() --- MarketplaceService:SetProductInfoUrl "http://banland.xyz/marketplace/productinfo?assetId=%d" --- end) --- pcall(function() --- MarketplaceService:SetDevProductInfoUrl "http://banland.xyz/marketplace/productDetails?productId=%d" --- end) --- pcall(function() --- MarketplaceService:SetPlayerOwnsAssetUrl "http://banland.xyz/ownership/hasasset?userId=%d&assetId=%d" --- end) - -local result, _ = pcall(function() +if not pcall(function() ScriptContext:AddStarterScript(37801172) -end) -if not result then +end) then pcall(function() ScriptContext:AddCoreScript(37801172, ScriptContext, "StarterScript") end)