From 7c9660e0cbf5568b9ae5b412e0ea8a451ee21c97 Mon Sep 17 00:00:00 2001 From: Lewin Kelly Date: Sat, 6 Apr 2024 11:15:28 +0100 Subject: [PATCH] Improve corescript and terrain plugin formatting --- defs.d.lua | 15 ++- luau/107893730.luau | 35 +++---- luau/20000001.luau | 4 +- luau/45284430.luau | 77 ++++++++------- luau/46295863.luau | 44 ++++----- luau/48488235.luau | 143 +++++++++++++++------------ luau/48488398.luau | 11 ++- luau/73157242.luau | 9 +- luau/89449008.luau | 29 +++--- luau/97188756.luau | 8 +- luau/join.luau | 19 ++-- luau/visit.luau | 10 +- terrain plugins/00 - terrain.luau | 11 ++- terrain plugins/01 - builder.luau | 145 ++++++++++++++-------------- terrain plugins/02 - remover.luau | 12 +-- terrain plugins/03 - elevation.luau | 24 ++--- terrain plugins/06 - craters.luau | 39 ++++---- terrain plugins/08 - roads.luau | 99 ++++++++++--------- terrain plugins/10 - stamper.luau | 7 +- 19 files changed, 393 insertions(+), 348 deletions(-) diff --git a/defs.d.lua b/defs.d.lua index cafbe90..41e95a7 100644 --- a/defs.d.lua +++ b/defs.d.lua @@ -3242,7 +3242,7 @@ export type SharedTable = any export type OpenCloudModel = any export type RBXScriptSignal = { - wait: (self: RBXScriptSignal) -> T..., + wait: (self: RBXScriptSignal, time: number?) -> T..., connect: (self: RBXScriptSignal, callback: (T...) -> ()) -> RBXScriptConnection, connectParallel: (self: RBXScriptSignal, callback: (T...) -> ()) -> RBXScriptConnection, once: (self: RBXScriptSignal, callback: (T...) -> ()) -> RBXScriptConnection, @@ -5384,6 +5384,7 @@ declare class GuiService extends Instance function ToggleGuiIsVisibleIfAllowed(self, guiType: EnumGuiType): nil function OpenBrowserWindow(self, url: string): nil + function SetGlobalSizeOffsetPixel(self, x: number, y: number): nil end declare class GuidRegistryService extends Instance @@ -5542,6 +5543,7 @@ declare class InsertService extends Instance function SetAssetVersionUrl(self, assetVersionUrl: string): nil function SetBaseSetsUrl(self, baseSetsUrl: string): nil function SetCollectionUrl(self, collectionUrl: string): nil + function SetUserSetsUrl(self, userSetsUrl: string): nil end declare class JointInstance extends Instance @@ -5969,7 +5971,11 @@ end declare class NetworkClient extends NetworkPeer ConnectionAccepted: RBXScriptSignal + ConnectionRejected: RBXScriptSignal ConnectionFailed: RBXScriptSignal + function Connect(self, serverAddress: string, serverPort: number, id: number, threadSleepTime: number): nil + function Disconnect(self, blockDuration: number?): nil + function PlayerConnect(self, userId: number, server: string, serverPort: number, clientPort: number?, threadSleepTime: number?, userName: string?): Player end declare class NetworkServer extends NetworkPeer @@ -6619,6 +6625,8 @@ declare class Player extends Instance function SetModerationAccessKey(self, moderationAccessKey: string): nil function SetSuperSafeChat(self, value: boolean): nil function UpdatePlayerBlocked(self, userId: number, blocked: boolean): nil + + function SetUnder13(self, value: boolean): nil end declare class PlayerEmulatorService extends Instance @@ -8358,7 +8366,8 @@ declare class VisibilityService extends Instance end declare class Visit extends Instance - function SetPing(self, url: string, interval: number): nil + function SetPing(self, pingUrl: string, interval: number): nil + function SetUploadUrl(self, url: string): nil end declare class Wire extends Instance @@ -8569,7 +8578,7 @@ declare _IS_STUDIO_JOIN: string declare _SERVER_ADDRESS: any declare _SERVER_PORT: string declare _CREATOR_ID: number -declare _USER_ID: string +declare _USER_ID: number declare _USER_NAME: any declare _MEMBERSHIP_TYPE: any declare _CHAR_APPEARANCE: string diff --git a/luau/107893730.luau b/luau/107893730.luau index 888e9cc..303dc1a 100644 --- a/luau/107893730.luau +++ b/luau/107893730.luau @@ -4,10 +4,11 @@ print "[Mercury]: Loaded corescript 107893730" -- this script creates the gui and sends the web requests for in game purchase prompts -local MarketplaceService = game:GetService "MarketplaceService" -local GuiService = game:GetService "GuiService" 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 @@ -27,7 +28,7 @@ end -------------------------------- Global Variables ---------------------------------------- -- utility variables -local baseUrl = string.lower(ContentProvider.BaseUrl) +local baseUrl = ContentProvider.BaseUrl -- data variables local currentProductInfo, currentAssetId, currentCurrencyType, currentCurrencyAmount, currentEquipOnPurchase, currentProductId, currentServerResponseTable @@ -390,12 +391,12 @@ local function updateAfterBalanceText(playerBalance, notRightBc) end if not keyWord then - return false + return false, false end local playerBalanceNumber = tonumber(playerBalance[keyWord]) if not playerBalanceNumber then - return false + return false, false end local afterBalanceNumber = playerBalanceNumber - currentCurrencyAmount @@ -434,11 +435,11 @@ end -- will get the player's balance of robux and tix, return in a table local function getPlayerBalance() local playerBalance - local success, errorCode = ypcall(function() + local ok, errorCode = ypcall(function() playerBalance = game:HttpGetAsync(`{getSecureApiBaseUrl()}currency/balance`) end) - if not success then + if not ok then print("Get player balance failed because", errorCode) return elseif playerBalance == "" then @@ -486,26 +487,26 @@ local function canPurchaseItem() local playerOwnsAsset = false local notRightBc = false local descText - local success = false + local ok = false if purchasingConsumable then local currentProductInfoRaw - success = ypcall(function() + ok = ypcall(function() currentProductInfoRaw = Game:HttpGetAsync( `{getSecureApiBaseUrl()}marketplace/productDetails?productid={currentProductId}` ) end) - if success then + if ok then currentProductInfo = HttpService:JSONDecode(currentProductInfoRaw) end else - success = ypcall(function() + ok = ypcall(function() currentProductInfo = MarketplaceService:GetProductInfo(currentAssetId) end) end - if currentProductInfo == nil or not success then + if currentProductInfo == nil or not ok then return true, nil, nil, @@ -755,7 +756,7 @@ 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 = game:GetService("InsertService"):LoadAsset(assetID) + local newTool = InsertService:LoadAsset(assetID) if not newTool then return nil end @@ -853,14 +854,14 @@ local function acceptPurchase() url ..= `purchase?productId={currentProductId}{currencyData}&purchasePrice={currentCurrencyAmount}&locationType=Game&locationId={Game.PlaceId}` end - local success, reason = ypcall(function() + 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 ", - success, + ok, "reason is", reason ) @@ -905,7 +906,7 @@ local function acceptPurchase() -- 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 success + and ok and currentAssetId and tonumber(currentProductInfo.AssetTypeId) == 19 then @@ -930,7 +931,7 @@ local function acceptPurchase() currentProductId ) else - userPurchaseActionsEnded(success) + userPurchaseActionsEnded(ok) end end diff --git a/luau/20000001.luau b/luau/20000001.luau index f7abe32..3b6a7c9 100644 --- a/luau/20000001.luau +++ b/luau/20000001.luau @@ -392,8 +392,8 @@ input.FocusLost:connect(function(enterPressed) end setfenv(fn, env) - local success, output = ypcall(fn) - if success then + local ok, output = ypcall(fn) + if ok then logEvent:Fire("= " .. tostring(output), Color3.new(0.5, 1, 0.5)) else logEvent:Fire("! " .. tostring(output), Color3.new(1, 0.5, 0.5)) diff --git a/luau/45284430.luau b/luau/45284430.luau index daa86d6..63579fe 100644 --- a/luau/45284430.luau +++ b/luau/45284430.luau @@ -17,8 +17,8 @@ local function ScopedConnect( instance, event, signalFunc, - syncFunc, - removeFunc + syncFunc: (() -> ())?, + removeFunc: (() -> ())? ) local eventConnection @@ -252,7 +252,11 @@ function RbxGui.CreateStyledMessageDialog(title, message, style, buttons) end local scrollMouseCount -function RbxGui.CreateDropDownMenu(items, onSelect, forRoblox: boolean?) +function RbxGui.CreateDropDownMenu( + items, + onSelect, + forRoblox: boolean? +): (Frame, (string) -> ()) local width = UDim.new(0, 100) local height = UDim.new(0, 32) @@ -1560,7 +1564,7 @@ function RbxGui.CreateTrueScrollingFrame() return scrollingFrame, controlFrame end -function RbxGui.CreateScrollingFrame(orderList, scrollStyle) +function RbxGui.CreateScrollingFrame(orderList: { GuiObject }?, scrollStyle) local frame = New "Frame" { Name = "ScrollingFrame", BackgroundTransparency = 1, @@ -1954,17 +1958,17 @@ function RbxGui.CreateScrollingFrame(orderList, scrollStyle) end reentrancyGuard = true RunService.Heartbeat:wait() - local success, err + local ok, err if style == "grid" then - success, err = pcall(function() + ok, err = pcall(function() layoutGridScrollBar() end) elseif style == "simple" then - success, err = pcall(function() + ok, err = pcall(function() layoutSimpleScrollBar() end) end - if not success then + if not ok then print(err) end moveDragger() @@ -2055,13 +2059,13 @@ function RbxGui.CreateScrollingFrame(orderList, scrollStyle) end -- local y = 0 - scrollDrag.MouseButton1Down:connect(function(_, y) + scrollDrag.MouseButton1Down:connect(function(_, y: number) if scrollDrag.Active then scrollStamp = tick() local mouseOffset = y - scrollDrag.AbsolutePosition.y local dragCon local upCon - dragCon = mouseDrag.MouseMoved:connect(function(_, y2) + dragCon = mouseDrag.MouseMoved:connect(function(_, y2: number) local barAbsPos = scrollbar.AbsolutePosition.y local barAbsSize = scrollbar.AbsoluteSize.y @@ -2705,7 +2709,15 @@ type TutorialPage = GuiObject & { PrevButton: TextButton, } -RbxGui.AddTutorialPage = function(tutorial, tutorialPage: TutorialPage) +function RbxGui.AddTutorialPage( + tutorial: { + TransitionFrame: Frame, + CurrentTutorialPage: ObjectValue, + Buttons: BoolValue, + Pages: Frame, + }, + tutorialPage: TutorialPage +) local transitionFrame = tutorial.TransitionFrame local currentPageValue = tutorial.CurrentTutorialPage @@ -2714,7 +2726,7 @@ RbxGui.AddTutorialPage = function(tutorial, tutorialPage: TutorialPage) tutorialPage.PrevButton.Parent = nil end - local children = tutorial.Pages:GetChildren() + local children = tutorial.Pages:GetChildren() :: { TutorialPage } if children and #children > 0 then tutorialPage.Name = "TutorialPage" .. (#children + 1) local previousPage: TutorialPage = children[#children] @@ -2751,13 +2763,11 @@ RbxGui.AddTutorialPage = function(tutorial, tutorialPage: TutorialPage) tutorialPage.PrevButton.Active = true tutorialPage.PrevButton.Visible = true end - - tutorialPage.Parent = tutorial.Pages else - --First child + -- First child tutorialPage.Name = "TutorialPage1" - tutorialPage.Parent = tutorial.Pages end + tutorialPage.Parent = tutorial.Pages end RbxGui.CreateSetPanel = function( @@ -2806,7 +2816,7 @@ RbxGui.CreateSetPanel = function( local arrayPosition = 1 local insertButtons = {} - local insertButtonCons = {} + local insertButtonCons: { RBXScriptConnection } = {} local contents local setGui @@ -3289,9 +3299,10 @@ RbxGui.CreateSetPanel = function( end local function buildInsertButton() - local insertButton = makeInsertAssetButton() - insertButton.Name = "InsertAssetButton" - insertButton.Visible = true + local insertButton = Hydrate(makeInsertAssetButton()) { + Name = "InsertAssetButton", + Visible = true, + } if Data.Category[Data.CurrentCategory].SetName == "High Scalability" @@ -3365,7 +3376,7 @@ RbxGui.CreateSetPanel = function( end end - local function loadSectionOfItems(setGui, rows, columns) + local function loadSectionOfItems(setGui, rows: number, columns: number) local pageSize = rows * columns if arrayPosition > #contents then @@ -3675,6 +3686,7 @@ RbxGui.CreateSetPanel = function( waterTypeChangedEvent end +-- We all know enums are just numbers in a trench coat local cm = Enum.CellMaterial local EnumMaterialNames = { [cm.Grass] = "Grass", @@ -3723,14 +3735,6 @@ for k, v in pairs(EnumMaterialNames) do StringChoices[v] = k end -local function getEnumFromName(choice) - return StringChoices[choice] -end - -local function getNameFromEnum(choice) - return EnumMaterialNames[choice] or MaterialNames[choice] -end - RbxGui.CreateTerrainMaterialSelector = function(size, position) local terrainMaterialSelectionChanged = Instance.new "BindableEvent" terrainMaterialSelectionChanged.Name = "TerrainMaterialSelectionChanged" @@ -3751,10 +3755,10 @@ RbxGui.CreateTerrainMaterialSelector = function(size, position) local materialToImageMap = {} - local currentMaterial = 1 + local currentMaterial: number = 1 local function updateMaterialChoice(choice) - currentMaterial = getEnumFromName(choice) + currentMaterial = (StringChoices[choice] :: unknown) :: number terrainMaterialSelectionChanged:Fire(currentMaterial) end @@ -3866,7 +3870,8 @@ RbxGui.CreateTerrainMaterialSelector = function(size, position) return end - local matName = getNameFromEnum(newMaterialType) + local matName = EnumMaterialNames[newMaterialType] + or MaterialNames[newMaterialType] local buttons = scrollFrame:GetChildren() for i = 1, #buttons do if @@ -4032,7 +4037,13 @@ RbxGui.CreateLoadingFrame = function(name, size, position) return loadingFrame, updateLoadingGuiPercent, cancelButtonClicked end -function RbxGui.CreatePluginFrame(name: string, size, position, scrollable, parent) +function RbxGui.CreatePluginFrame( + name: string, + size, + position, + scrollable, + parent +) local function createMenuButton( size, position, diff --git a/luau/46295863.luau b/luau/46295863.luau index a7be9ea..05e3a59 100644 --- a/luau/46295863.luau +++ b/luau/46295863.luau @@ -1,3 +1,4 @@ +--!strict -- CoreGui.RobloxGui.CoreScripts/Settings print "[Mercury]: Loaded corescript 46295863" @@ -50,10 +51,10 @@ local mainShield local inStudioMode = UserSettings().GameSettings:InStudioMode() local macClient = false -local success, isMac = pcall(function() +local ok, isMac = pcall(function() return not game.GuiService.IsWindows end) -macClient = success and isMac +macClient = ok and isMac local function Color3I(r, g, b) return Color3.new(r / 255, g / 255, b / 255) @@ -183,31 +184,30 @@ end local function resetLocalCharacter() local player = game.Players.LocalPlayer - if - player - and player.Character - and player.Character:FindFirstChild "Humanoid" - then - player.Character.Humanoid.Health = 0 + if player and player.Character then + local humanoid = (player.Character:FindFirstChild "Humanoid") :: Humanoid + if humanoid then + humanoid.Health = 0 + end end end local function createTextButton( - text, - style, - fontSize, - buttonSize, - buttonPosition + text: string, + style: EnumItem, + fontSize: EnumItem, + buttonSize: UDim2, + buttonPosition: UDim2 ) - local newTextButton = Instance.new "TextButton" - newTextButton.Font = Enum.Font.Arial - newTextButton.FontSize = fontSize - newTextButton.Size = buttonSize - newTextButton.Position = buttonPosition - newTextButton.Style = style - newTextButton.TextColor3 = Color3.new(1, 1, 1) - newTextButton.Text = text - return newTextButton + return New "TextButton" { + Font = Enum.Font.Arial, + FontSize = fontSize, + Size = buttonSize, + Position = buttonPosition, + Style = style, + TextColor3 = Color3.new(1, 1, 1), + Text = text, + } end local function CreateTextButtons(frame, buttons, yPos, ySize) diff --git a/luau/48488235.luau b/luau/48488235.luau index 8cd8397..96ea32f 100644 --- a/luau/48488235.luau +++ b/luau/48488235.luau @@ -1,9 +1,12 @@ +--!strict -- CoreGui.RobloxGui.CoreScripts/PlayerListScript print "[Mercury]: Loaded corescript 48488235" local RunService = game:GetService "RunService" -local New = (require "../Modules/New").New +local News = require "../Modules/New" +local New = News.New +local Hydrate = News.Hydrate local log = require "../Modules/Logger" -------------------- @@ -19,24 +22,24 @@ local ADMINS = { } local Images = { - bottomDark = "94691904", - bottomLight = "94691940", - midDark = "94691980", - midLight = "94692025", - LargeDark = "96098866", - LargeLight = "96098920", - LargeHeader = "96097470", - NormalHeader = "94692054", - LargeBottom = "96397271", - NormalBottom = "94754966", - DarkBluePopupMid = "97114905", - LightBluePopupMid = "97114905", - DarkPopupMid = "97112126", - LightPopupMid = "97109338", - DarkBluePopupTop = "97114838", - DarkBluePopupBottom = "97114758", - DarkPopupBottom = "100869219", - LightPopupBottom = "97109175", + bottomDark = 94691904, + bottomLight = 94691940, + midDark = 94691980, + midLight = 94692025, + LargeDark = 96098866, + LargeLight = 96098920, + LargeHeader = 96097470, + NormalHeader = 94692054, + LargeBottom = 96397271, + NormalBottom = 94754966, + DarkBluePopupMid = 97114905, + LightBluePopupMid = 97114905, + DarkPopupMid = 97112126, + LightPopupMid = 97109338, + DarkBluePopupTop = 97114838, + DarkBluePopupBottom = 97114758, + DarkPopupBottom = 100869219, + LightPopupBottom = 97109175, } local BASE_TWEEN = 0.25 @@ -667,7 +670,16 @@ local AddId = 0 -- Score -- ID -- MyTeam (team ENRTY(not actual team) I am currently on) -local PlayerFrames = {} +local PlayerFrames: { + { + Frame: Frame, + Player: Player, + Score: number, + ID: number, + MyTeam: nil, + } +} = + {} -- intermediate ordered frame array, composed of Entrys of -- Frame -- MyTeam (my team object) @@ -686,9 +698,9 @@ local MiddleFrameBackgrounds = {} local LastClick = 0 local ButtonCooldown = 0.25 -local OnIos = false +-- local OnIos = false -- pcall(function() --- OnIos = Game:GetService("UserInputService").TouchEnabled +-- OnIos = UserInputService.TouchEnabled -- end) -- you get 200 of x screen space per stat added, start width 16% @@ -720,10 +732,10 @@ local NeutralTeamLock = false local ScrollWheelConnections: { RBXScriptConnection }? = {} -local DefaultListSize = 8 -if not OnIos then - DefaultListSize = 12 -end +-- local DefaultListSize = 8 +-- if not OnIos then +-- DefaultListSize = 12 +-- end local DidMinimizeDrag = false --local PlaceCreatorId=game.CreatorId @@ -881,7 +893,7 @@ end player player to change rank of nrank new integer rank to give player --]] -local function SetPrivilegeRank(player, nrank) +local function SetPrivilegeRank(player, nrank: number) while player.PersonalServerRank < nrank do PersonalServerService:Promote(player) end @@ -1068,14 +1080,14 @@ end player player object to check if friends with @Return: enum of friend status --]] -local function GetFriendStatus(player) +local function GetFriendStatus(player: Player) if player == game.Players.LocalPlayer then return Enum.FriendStatus.NotFriend end - local success, result = pcall(function() + local ok, result = pcall(function() return game.Players.LocalPlayer:GetFriendStatus(player) end) - if success then + if ok then return result end return Enum.FriendStatus.NotFriend @@ -1116,18 +1128,22 @@ end ------------------------------------ -- Player Entry Handling ------------------------------------ + +type Plr = { + Score: number, + Player: Player, +} + --[[ used by lua's table.sort to sort player entries --]] -local function PlayerSortFunction(a, b) +local function PlayerSortFunction(a: Plr, b: Plr) -- prevents flipping out leaderboard if a.Score == b.Score then return a.Player.Name:upper() < b.Player.Name:upper() - end - if not a.Score then + elseif not a.Score then return false - end - if not b.Score then + elseif not b.Score then return true end return a.Score < b.Score @@ -1822,7 +1838,7 @@ end local function ToggleMaximize() IsMaximized.Value = not IsMaximized.Value - RecreateScoreColumns(PlayerFrames) --done to re-position stat names NOTE: optimize-able + RecreateScoreColumns(PlayerFrames) -- done to re-position stat names NOTE: optimize-able end --[[ @@ -2176,7 +2192,7 @@ end) last is this the last element of the popup menu @Return: a popup menu button --]] -local function MakePopupButton(nparent, ntext, index, last) +local function MakePopupButton(nparent, ntext, index, last: boolean?) local tobj = New "ImageButton" { Name = "ReportButton", BackgroundTransparency = 1, @@ -2202,19 +2218,12 @@ local function MakePopupButton(nparent, ntext, index, last) if index == 0 then tobj.Image = "http://banland.xyz/asset?id=97108784" elseif last then - if index % 2 == 1 then - tobj.Image = "http://banland.xyz/asset?id=" - .. Images.LightPopupBottom - else - tobj.Image = "http://banland.xyz/asset?id=" - .. Images.DarkPopupBottom - end + tobj.Image = index % 2 == 1 + and "http://banland.xyz/asset?id=" .. Images.LightPopupBottom + or "http://banland.xyz/asset?id=" .. Images.DarkPopupBottom else - if index % 2 == 1 then - tobj.Image = "http://banland.xyz/asset?id=97112126" - else - tobj.Image = "http://banland.xyz/asset?id=97109338" - end + tobj.Image = index % 2 == 1 and "http://banland.xyz/asset?id=97112126" + or "http://banland.xyz/asset?id=97109338" end return tobj end @@ -2229,8 +2238,9 @@ local function InitMovingPanel(entry, player) if PopUpPanel then PopUpPanel:Destroy() end - PopUpPanel = PopUpPanelTemplate:Clone() - PopUpPanel.Parent = PopUpClipFrame + PopUpPanel = Hydrate(PopUpPanelTemplate:Clone()) { + Parent = PopUpClipFrame, + } local nextIndex = 2 local friendStatus = GetFriendStatus(player) @@ -2563,7 +2573,11 @@ local function AddMiddleBGFrame() nBGFrame.Parent = ListFrame table.insert(MiddleFrameBackgrounds, nBGFrame) - if #MiddleFrameBackgrounds < DefaultListSize and not DidMinimizeDrag then + if + #MiddleFrameBackgrounds --[[DefaultListSize]] + < 12 + and not DidMinimizeDrag + then -- print "readjusting bottom clip" DefaultBottomClipPos = -1 + (#MiddleFrameBackgrounds * MiddleBGTemplate.Size.Y.Scale) @@ -2725,13 +2739,15 @@ local function AddNeutralTeam() end NeutralTeamLock = true - local defaultTeam = Instance.new "Team" - defaultTeam.TeamColor = BrickColor.new "White" - defaultTeam.Name = "Neutral" - local nentry = {} - nentry.MyTeam = defaultTeam - nentry.MyPlayers = {} - nentry.Frame = MiddleTemplate:Clone() + local defaultTeam = New "Team" { + TeamColor = BrickColor.new "White", + Name = "Neutral", + } + local nentry = { + MyTeam = defaultTeam, + MyPlayers = {}, + Frame = MiddleTemplate:Clone(), + } WaitForChild(WaitForChild(nentry.Frame, "TitleFrame"), "Title").Text = defaultTeam.Name nentry.Frame.TitleFrame.Position = UDim2.new( @@ -2921,10 +2937,11 @@ local function InsertPlayerFrame(nplayer) true ) UpdateMinimize() - local nentry = {} - nentry.Frame = nFrame - nentry.Player = nplayer - nentry.ID = AddId + local nentry = { + Frame = nFrame, + Player = nplayer, + ID = AddId, + } AddId += 1 table.insert(PlayerFrames, nentry) if #TeamFrames ~= 0 then diff --git a/luau/48488398.luau b/luau/48488398.luau index a654ec3..bf31617 100644 --- a/luau/48488398.luau +++ b/luau/48488398.luau @@ -1,6 +1,7 @@ -- CoreGui.RobloxGui.CoreScripts/NotificationScript print "[Mercury]: Loaded corescript 48488398" +local GuiService = game:GetService "GuiService" local TeleportService = game:GetService "TeleportService" local function waitForProperty(instance, property) @@ -129,7 +130,7 @@ game.Players.FriendRequestEvent:connect(function(fromPlayer, toPlayer, event) if fromPlayer == localPlayer then if event == Enum.FriendRequestEvent.Accept then - game:GetService("GuiService"):SendNotification( + GuiService:SendNotification( "You are Friends", `With {toPlayer.Name}!`, `http://banland.xyz/thumbs/avatar.ashx?userId={toPlayer.userId}&x=48&y=48`, @@ -142,7 +143,7 @@ game.Players.FriendRequestEvent:connect(function(fromPlayer, toPlayer, event) if friendRequestBlacklist[fromPlayer] then return end -- previously cancelled friend request, we don't want it! - game:GetService("GuiService"):SendNotification( + GuiService:SendNotification( "Friend Request", `From {fromPlayer.Name}`, `http://banland.xyz/thumbs/avatar.ashx?userId={fromPlayer.userId}&x=48&y=48`, @@ -152,7 +153,7 @@ game.Players.FriendRequestEvent:connect(function(fromPlayer, toPlayer, event) end ) elseif event == Enum.FriendRequestEvent.Accept then - game:GetService("GuiService"):SendNotification( + GuiService:SendNotification( "You are Friends", `With {fromPlayer.Name}!`, `http://banland.xyz/thumbs/avatar.ashx?userId={fromPlayer.userId}&x=48&y=48`, @@ -276,10 +277,10 @@ if teleportEnabled then yesCon = popup.AcceptButton.MouseButton1Click:connect(function() killCons() - local success, err = pcall(function() + local ok, err = pcall(function() TeleportService:TeleportImpl(placeId, spawnName) end) - if not success then + if not ok then showOneButton() popup.PopupText.Text = err local clickCon diff --git a/luau/73157242.luau b/luau/73157242.luau index 480efe6..6019bcb 100644 --- a/luau/73157242.luau +++ b/luau/73157242.luau @@ -2,6 +2,7 @@ print "[Mercury]: Loaded corescript 73157242" local ChangeHistoryService = game:GetService "ChangeHistoryService" +local InsertService = game:GetService "InsertService" local RbxStamper = {} @@ -522,11 +523,11 @@ local function findConfigAtMouseTarget(Mouse: Mouse, stampData: Instance) local hitPlane = false local targetPart - local success = pcall(function() + local ok = pcall(function() targetPart = Mouse.Target end) - if not success then -- or targetPart == nil then + if not ok then -- or targetPart == nil then return admissibleConfig, targetConfig end @@ -872,13 +873,13 @@ RbxStamper.GetStampModel = function(assetId, terrainShape, useAssetVersionId) local loading = true if useAssetVersionId then loader = coroutine.create(function() - root = game:GetService("InsertService"):LoadAssetVersion(assetId) + root = InsertService:LoadAssetVersion(assetId) loading = false end) coroutine.resume(loader) else loader = coroutine.create(function() - root = game:GetService("InsertService"):LoadAsset(assetId) + root = InsertService:LoadAsset(assetId) loading = false end) coroutine.resume(loader) diff --git a/luau/89449008.luau b/luau/89449008.luau index 6042f4f..bcabcab 100644 --- a/luau/89449008.luau +++ b/luau/89449008.luau @@ -1,6 +1,8 @@ -- CoreGui.RobloxGui.Backpack.CoreScripts/BackpackScripts/Back (1?) print "[Mercury]: Loaded corescript 89449008" +local UserInputService = game:GetService "UserInputService" + local News = require "../Modules/New" local New = News.New local Hydrate = News.Hydrate @@ -22,7 +24,7 @@ end local function IsTouchDevice() local touchEnabled = false pcall(function() - touchEnabled = Game:GetService("UserInputService").TouchEnabled + touchEnabled = UserInputService.TouchEnabled end) return touchEnabled end @@ -87,14 +89,15 @@ scrollFrame.Position = UDim2.new(0, 0, 0, 30) scrollFrame.Size = UDim2.new(1, 0, 1, -30) scrollFrame.Parent = backpack.Gear.GearGrid -local scrollBar = Instance.new "Frame" -scrollBar.Name = "ScrollBar" -scrollBar.BackgroundTransparency = 0.9 -scrollBar.BackgroundColor3 = Color3.new(1, 1, 1) -scrollBar.BorderSizePixel = 0 -scrollBar.Size = UDim2.new(0, 17, 1, -36) -scrollBar.Position = UDim2.new(0, 0, 0, 18) -scrollBar.Parent = scroller +New "Frame" { + Name = "ScrollBar", + BackgroundTransparency = 0.9, + BackgroundColor3 = Color3.new(1, 1, 1), + BorderSizePixel = 0, + Size = UDim2.new(0, 17, 1, -36), + Position = UDim2.new(0, 0, 0, 18), + Parent = scroller, +} scrollDown.Position = UDim2.new(0, 0, 1, -17) @@ -104,9 +107,11 @@ scrollDown.Parent = scroller local scrollFrameLoadout, scrollUpLoadout, scrollDownLoadout, recalculateScrollLoadout = RbxGui.CreateScrollingFrame() -scrollFrameLoadout.Position = UDim2.new(0, 0, 0, 0) -scrollFrameLoadout.Size = UDim2.new(1, 0, 1, 0) -scrollFrameLoadout.Parent = backpack.Gear.GearLoadouts.LoadoutsList +Hydrate(scrollFrameLoadout) { + Position = UDim2.new(0, 0, 0, 0), + Size = UDim2.new(1, 0, 1, 0), + Parent = backpack.Gear.GearLoadouts.LoadoutsList, +} for i = 1, 4 do New "TextButton" { diff --git a/luau/97188756.luau b/luau/97188756.luau index af22a98..e8a3f7a 100644 --- a/luau/97188756.luau +++ b/luau/97188756.luau @@ -10,7 +10,7 @@ local New = (require "../Modules/New").New local forceChatGUI = false -- Utility functions + Globals -local function WaitForChild(parent, childName) +local function WaitForChild(parent: Instance, childName) while parent:FindFirstChild(childName) == nil do parent.ChildAdded:wait(0.03) end @@ -629,11 +629,11 @@ function Chat:CreateChatBar() } -- Engine has code to offset the entire world, so if we do it by -20 pixels nothing gets in our chat's way - --GuiService:SetGlobalSizeOffsetPixel(0, -20) - local success = pcall(function() + -- GuiService:SetGlobalSizeOffsetPixel(0, -20) + local ok = pcall(function() GuiService:SetGlobalGuiInset(0, 0, 0, 20) end) - if not success then + if not ok then GuiService:SetGlobalSizeOffsetPixel(0, -20) end -- ChatHotKey is '/' diff --git a/luau/join.luau b/luau/join.luau index ad77375..a706080 100644 --- a/luau/join.luau +++ b/luau/join.luau @@ -145,12 +145,12 @@ local function requestCharacter(replicator) setLoadingMessage "Requesting character" - local success, err = pcall(function() + local ok, err = pcall(function() replicator:RequestCharacter() setLoadingMessage "Waiting for character" end) - if not success then + if not ok then reportError(err) return end @@ -160,7 +160,7 @@ end local function onConnectionAccepted(_, replicator) local waitingForMarker = true - local success, err = pcall(function() + local ok, err = pcall(function() Visit:SetPing(_PING_URL, 30) loadingState += 1 @@ -177,7 +177,7 @@ local function onConnectionAccepted(_, replicator) end) end) - if not success then + if not ok then reportError(err) return end @@ -209,7 +209,7 @@ local function onPlayerIdled(idleTime) idleTime / 60 ) ) - Client:disconnect() + Client:Disconnect() end end @@ -218,7 +218,7 @@ end pcall(function() settings().Diagnostics:LegacyScriptMode() end) -local success, err = pcall(function() +local ok, err = pcall(function() game:SetRemoteBuildMode(true) setLoadingMessage "Connecting to server" @@ -238,7 +238,7 @@ local success, err = pcall(function() ) end) if not playerConnectSuccess then - --Old player connection scheme + -- Old player connection scheme player = Players:CreateLocalPlayer(_USER_ID) Client:Connect("_SERVER_ADDRESS", _SERVER_PORT, 0, threadSleepTime) end @@ -262,13 +262,10 @@ local success, err = pcall(function() Visit:SetUploadUrl "" end) -if not success then +if not ok then reportError(err) end --- TODO: Async get? --- loadfile ""("", -1, 0) -- wtf - pcall(function() game:SetScreenshotInfo "" end) diff --git a/luau/visit.luau b/luau/visit.luau index f37c857..d398609 100644 --- a/luau/visit.luau +++ b/luau/visit.luau @@ -84,7 +84,7 @@ end) workspace:SetPhysicsThrottleEnabled(true) -local function doVisit() +local ok, err = pcall(function() message.Text = "Loading Game" pcall(function() @@ -96,7 +96,7 @@ local function doVisit() message.Text = "Creating Player" - player = game:GetService("Players"):CreateLocalPlayer(0) + player = Players:CreateLocalPlayer(0) player.CharacterAppearance = "" local propExists, canAutoLoadChar = false, false @@ -116,11 +116,9 @@ local function doVisit() pcall(function() player:SetAccountAge(0) end) -end +end) -local success, err = pcall(doVisit) - -if success then +if ok then message.Parent = nil else print(err) diff --git a/terrain plugins/00 - terrain.luau b/terrain plugins/00 - terrain.luau index a5f4792..ac6f424 100644 --- a/terrain plugins/00 - terrain.luau +++ b/terrain plugins/00 - terrain.luau @@ -3,6 +3,9 @@ while game == nil do wait() end +local ChangeHistoryService = game:GetService "ChangeHistoryService" +local CoreGui = game:GetService "CoreGui" + --------------- --PLUGIN SETUP- --------------- @@ -123,7 +126,7 @@ local hideGenerateConformation = false --screengui local g = Instance.new "ScreenGui" g.Name = "TerrainCreatorGui" -g.Parent = game:GetService "CoreGui" +g.Parent = CoreGui -- UI gui load. Required for sliders. local RbxGui = LoadLibrary "RbxGui" @@ -856,8 +859,7 @@ function GenerateTerrain() for x = 1 + xpos2, generateOptions.width - 2 + xpos2 do -- End on cancel. if cancelValues.cancelActions then - game:GetService("ChangeHistoryService") - :SetWaypoint "CancelGenerate" + ChangeHistoryService:SetWaypoint "CancelGenerate" UnloadProgressBar() return end @@ -914,8 +916,7 @@ function GenerateTerrain() for x = 1 + xpos2, generateOptions.width - 2 + xpos2 do -- End on cancel. if cancelValues.cancelActions then - game:GetService("ChangeHistoryService") - :SetWaypoint "GenerateGenerate" + ChangeHistoryService:SetWaypoint "GenerateGenerate" UnloadProgressBar() return end diff --git a/terrain plugins/01 - builder.luau b/terrain plugins/01 - builder.luau index b981b1c..9e46c1c 100644 --- a/terrain plugins/01 - builder.luau +++ b/terrain plugins/01 - builder.luau @@ -16,9 +16,7 @@ local On, Off local plugin = PluginManager():CreatePlugin() local mouse = plugin:GetMouse() -mouse.Button1Down:connect(function() - onClicked(mouse) -end) + local toolbar = plugin:CreateToolbar "Terrain" local toolbarbutton = toolbar:CreateButton("Builder", "Builder", "builder.png") toolbarbutton.Click:connect(function() @@ -296,78 +294,81 @@ CreateStandardLabel( -- Function to connect to the mouse button 1 down event. This is what will run when the user clicks. -- Adding and autowedging done here. -- mouse - Mouse data. -function onClicked(mouseC) - if on then - local cellPos = WorldToCellPreferEmpty( - c, - Vector3.new(mouseC.Hit.x, mouseC.Hit.y, mouseC.Hit.z) - ) - local x = cellPos.x - local y = cellPos.y - local z = cellPos.z - - local solidCellPos = WorldToCellPreferSolid( - c, - Vector3.new(mouseC.Hit.x, mouseC.Hit.y, mouseC.Hit.z) - ) - - local celMat = - GetCell(c, solidCellPos.x, solidCellPos.y, solidCellPos.z) - local success = false - - if celMat.Value > 0 then - selectionProps.terrainMaterial = celMat.Value - selectionProps.isWater, selectionProps.waterForce, selectionProps.waterDirection = - GetWaterCell(c, solidCellPos.X, solidCellPos.Y, solidCellPos.Z) - else - if 0 == selectionProps.terrainMaterial then - -- It was nothing, give it a default type and the plane intersection. - selectionProps.isWater = false - selectionProps.terrainMaterial = 1 - end - - success, cellPos = PlaneIntersection( - Vector3.new(mouseC.Hit.x, mouseC.Hit.y, mouseC.Hit.z) - ) - if not success then - cellPos = solidCellPos - end - - x = cellPos.x - y = cellPos.y - z = cellPos.z - end - - if selectionProps.isWater and 17 == selectionProps.terrainMaterial then - SetWaterCell( - c, - x, - y, - z, - selectionProps.waterForce, - selectionProps.waterDirection - ) - else - SetCell(c, x, y, z, selectionProps.terrainMaterial, 0, 0) - end - - if properties.autoWedgeEnabled then - AutoWedge( - c, - Region3int16.new( - Vector3int16.new(x - 1, y - 1, z - 1), - Vector3int16.new(x + 1, y + 1, z + 1) - ) - ) - end - - -- Mark undo point. - ChangeHistoryService:SetWaypoint "Builder" - - UpdatePosition(mouseC.Hit) +local function onClicked() + if not on then + return end + + local cellPos = WorldToCellPreferEmpty( + c, + Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z) + ) + local x = cellPos.x + local y = cellPos.y + local z = cellPos.z + + local solidCellPos = WorldToCellPreferSolid( + c, + Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z) + ) + + local celMat = GetCell(c, solidCellPos.x, solidCellPos.y, solidCellPos.z) + local success = false + + if celMat.Value > 0 then + selectionProps.terrainMaterial = celMat.Value + selectionProps.isWater, selectionProps.waterForce, selectionProps.waterDirection = + GetWaterCell(c, solidCellPos.X, solidCellPos.Y, solidCellPos.Z) + else + if 0 == selectionProps.terrainMaterial then + -- It was nothing, give it a default type and the plane intersection. + selectionProps.isWater = false + selectionProps.terrainMaterial = 1 + end + + success, cellPos = PlaneIntersection( + Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z) + ) + if not success then + cellPos = solidCellPos + end + + x = cellPos.x + y = cellPos.y + z = cellPos.z + end + + if selectionProps.isWater and 17 == selectionProps.terrainMaterial then + SetWaterCell( + c, + x, + y, + z, + selectionProps.waterForce, + selectionProps.waterDirection + ) + else + SetCell(c, x, y, z, selectionProps.terrainMaterial, 0, 0) + end + + if properties.autoWedgeEnabled then + AutoWedge( + c, + Region3int16.new( + Vector3int16.new(x - 1, y - 1, z - 1), + Vector3int16.new(x + 1, y + 1, z + 1) + ) + ) + end + + -- Mark undo point. + ChangeHistoryService:SetWaypoint "Builder" + + UpdatePosition(mouse.Hit) end +mouse.Button1Down:connect(onClicked) + mouseHighlighter.OnClicked = onClicked -- Run when the popup is activated. diff --git a/terrain plugins/02 - remover.luau b/terrain plugins/02 - remover.luau index b46fb1f..90e3e31 100644 --- a/terrain plugins/02 - remover.luau +++ b/terrain plugins/02 - remover.luau @@ -19,9 +19,7 @@ local On, Off --------------- local plugin = PluginManager():CreatePlugin() local mouse = plugin:GetMouse() -mouse.Button1Down:connect(function() - onClicked(mouse) -end) + local toolbar = plugin:CreateToolbar "Terrain" local toolbarbutton = toolbar:CreateButton("Remover", "Remover", "destroyer.png") @@ -251,11 +249,11 @@ CreateStandardLabel( -- Function to connect to the mouse button 1 down event. This is what will run when the user clicks. -- mouse - Mouse data. -function onClicked(mouse2) +function onClicked() if on then local cellPos = WorldToCellPreferSolid( c, - Vector3.new(mouse2.Hit.x, mouse2.Hit.y, mouse2.Hit.z) + Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z) ) local x = cellPos.x local y = cellPos.y @@ -266,7 +264,7 @@ function onClicked(mouse2) -- Mark undo point. ChangeHistoryService:SetWaypoint "Remover" - UpdatePosition(mouse2.Hit) + UpdatePosition(mouse.Hit) if properties.autoWedgeEnabled then AutoWedge( @@ -280,6 +278,8 @@ function onClicked(mouse2) end end +mouse.Button1Down:connect(onClicked) + mouseHighlighter.OnClicked = onClicked -- Run when the popup is activated. diff --git a/terrain plugins/03 - elevation.luau b/terrain plugins/03 - elevation.luau index 4907625..4a593d5 100644 --- a/terrain plugins/03 - elevation.luau +++ b/terrain plugins/03 - elevation.luau @@ -16,9 +16,7 @@ local On, Off local plugin = PluginManager():CreatePlugin() local mouse = plugin:GetMouse() -mouse.Button1Down:connect(function() - onClicked(mouse) -end) + local toolbar = plugin:CreateToolbar "Terrain" local toolbarbutton = toolbar:CreateButton( "Elevation Adjuster", @@ -557,18 +555,18 @@ end local mousedown = false -- Run when the mouse gets clicked. If the click is on terrain, then it will be used as the starting point of the elevation area. -function onClicked(mouse2) +local function onClicked() if on then oldheightmap = {} heightmap = {} local cellPos = WorldToCellPreferEmpty( c, - Vector3.new(mouse2.Hit.x, mouse2.Hit.y, mouse2.Hit.z) + Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z) ) local solidCell = WorldToCellPreferSolid( c, - Vector3.new(mouse2.Hit.x, mouse2.Hit.y, mouse2.Hit.z) + Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z) ) local success = false @@ -576,7 +574,7 @@ function onClicked(mouse2) if 0 == GetCell(c, solidCell.X, solidCell.Y, solidCell.Z).Value then --print('Plane Intersection happens') success, cellPos = PlaneIntersection( - Vector3.new(mouse2.Hit.x, mouse2.Hit.y, mouse2.Hit.z) + Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z) ) if not success then cellPos = solidCell @@ -604,25 +602,25 @@ function onClicked(mouse2) mouseHighlighter:DisablePreview() mousedown = true - local originalY = mouse2.Y + local originalY = mouse.Y local prevY = originalY local d = 0 local range = 0 while mousedown == true do - if math.abs(mouse2.Y - prevY) >= 5 then - prevY = mouse2.Y + if math.abs(mouse.Y - prevY) >= 5 then + prevY = mouse.Y local r2 = elevationOptions.r + math.floor( 50 * 1 / elevationOptions.s * math.abs(originalY - prevY) - / mouse2.ViewSizeY + / mouse.ViewSizeY ) if r2 > range then range = r2 end - d = math.floor(50 * (originalY - prevY) / mouse2.ViewSizeY) + d = math.floor(50 * (originalY - prevY) / mouse.ViewSizeY) elevate(x, y, z, elevationOptions.r, r2, d, range) end wait() @@ -631,6 +629,8 @@ function onClicked(mouse2) end end +mouse.Button1Down:connect(onClicked) + mouseHighlighter.OnClicked = onClicked mouse = plugin:GetMouse() mouse.Button1Up:connect(function() diff --git a/terrain plugins/06 - craters.luau b/terrain plugins/06 - craters.luau index c763785..fbdb19a 100644 --- a/terrain plugins/06 - craters.luau +++ b/terrain plugins/06 - craters.luau @@ -15,9 +15,7 @@ local On, Off local this = PluginManager():CreatePlugin() local mouse = this:GetMouse() -mouse.Button1Down:connect(function() - onClicked(mouse) -end) + local toolbar = this:CreateToolbar "Terrain" local toolbarbutton = toolbar:CreateButton("Crater", "Crater", "craters.png") toolbarbutton.Click:connect(function() @@ -119,24 +117,27 @@ function dist(x1, y1, x2, y2) end local debounce = false -function onClicked(mouseC) - if on and not debounce then - debounce = true - local cellPos = WorldToCellPreferSolid( - c, - Vector3.new(mouseC.Hit.x, mouseC.Hit.y, mouseC.Hit.z) - ) - local x = cellPos.x - local y = cellPos.y - local z = cellPos.z - - makeCrater(x, y, z, r, d) - - debounce = false - ChangeHistoryService:SetWaypoint "Crater" +mouse.Button1Down:connect(function() + if not on or debounce then + return end -end + + debounce = true + + local cellPos = WorldToCellPreferSolid( + c, + Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z) + ) + local x = cellPos.x + local y = cellPos.y + local z = cellPos.z + + makeCrater(x, y, z, r, d) + + debounce = false + ChangeHistoryService:SetWaypoint "Crater" +end) On = function() if not c then diff --git a/terrain plugins/08 - roads.luau b/terrain plugins/08 - roads.luau index 19c88e1..44798a0 100644 --- a/terrain plugins/08 - roads.luau +++ b/terrain plugins/08 - roads.luau @@ -14,9 +14,6 @@ local On, Off local this = PluginManager():CreatePlugin() local mouse = this:GetMouse() -mouse.Button1Down:connect(function() - onClicked(mouse) -end) local toolbar = this:CreateToolbar "Terrain" local toolbarbutton = toolbar:CreateButton("Roads", "Roads", "roads.png") toolbarbutton.Click:connect(function() @@ -222,56 +219,58 @@ function PlaneIntersection(vectorPos) return success, cellPos end -function onClicked(mouseC) - if on then - local cellPos = WorldToCellPreferEmpty( - c, - Vector3.new(mouseC.Hit.x, mouseC.Hit.y, mouseC.Hit.z) +mouse.Button1Down:connect(function() + if not on then + return + end + + local cellPos = WorldToCellPreferEmpty( + c, + Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z) + ) + local solidCell = WorldToCellPreferSolid( + c, + Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z) + ) + local success = false + + -- If nothing was hit, do the plane intersection. + if 0 == GetCell(c, solidCell.X, solidCell.Y, solidCell.Z).Value then + --print('Plane Intersection happens') + success, cellPos = PlaneIntersection( + Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z) ) - local solidCell = WorldToCellPreferSolid( - c, - Vector3.new(mouseC.Hit.x, mouseC.Hit.y, mouseC.Hit.z) - ) - local success = false - - -- If nothing was hit, do the plane intersection. - if 0 == GetCell(c, solidCell.X, solidCell.Y, solidCell.Z).Value then - --print('Plane Intersection happens') - success, cellPos = PlaneIntersection( - Vector3.new(mouseC.Hit.x, mouseC.Hit.y, mouseC.Hit.z) - ) - if not success then - cellPos = solidCell - end - end - - local x = cellPos.x - local y = cellPos.y - local z = cellPos.z - - if mode == 0 then - x1 = x - y1 = z - h = y - mode = 1 - - -- first click determines default material - local celMat = GetCell(c, x, y, z) - if celMat.Value > 0 then - DefaultTerrainMaterial = celMat.Value - else - if 0 == DefaultTerrainMaterial then - DefaultTerrainMaterial = 1 - end - end - elseif mode == 1 then - x2 = x - y2 = z - makePath(x1, y1, x2, y2, h, true) - mode = 0 + if not success then + cellPos = solidCell end end -end + + local x = cellPos.x + local y = cellPos.y + local z = cellPos.z + + if mode == 0 then + x1 = x + y1 = z + h = y + mode = 1 + + -- first click determines default material + local celMat = GetCell(c, x, y, z) + if celMat.Value > 0 then + DefaultTerrainMaterial = celMat.Value + else + if 0 == DefaultTerrainMaterial then + DefaultTerrainMaterial = 1 + end + end + elseif mode == 1 then + x2 = x + y2 = z + makePath(x1, y1, x2, y2, h, true) + mode = 0 + end +end) On = function() if not c then diff --git a/terrain plugins/10 - stamper.luau b/terrain plugins/10 - stamper.luau index b716af0..dbbd5d0 100644 --- a/terrain plugins/10 - stamper.luau +++ b/terrain plugins/10 - stamper.luau @@ -2,6 +2,9 @@ while game == nil do wait() end +local ContentProvider = game:GetService "ContentProvider" +local CoreGui = game:GetService "CoreGui" + --------------- --PLUGIN SETUP- --------------- @@ -66,7 +69,7 @@ Spawn(function() RbxStamper = LoadLibrary "RbxStamper" end) -local BaseUrl = game:GetService("ContentProvider").BaseUrl:lower() +local BaseUrl = ContentProvider.BaseUrl:lower() ----------------------- --FUNCTION DEFINITIONS- @@ -354,7 +357,7 @@ function createGui() ) setPanelVisibility(false) - currStampGui.Parent = game:GetService "CoreGui" + currStampGui.Parent = CoreGui waterTypeChangedEvent.Event:connect(function(waterTable) waterForceAndDirection = waterTable