Add type definitions and fix type errors in corescripts

This commit is contained in:
Lewin Kelly 2023-08-14 23:46:25 +01:00
parent 3c7499eb2e
commit de20338362
16 changed files with 11254 additions and 86 deletions

11146
defs.d.lua Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,15 @@
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"
-- wait for important items to appear
while not Game do
wait(0.1)
end
while not game:GetService "MarketplaceService" do
while not MarketplaceService do
wait(0.1)
MarketplaceService = game:GetService "MarketplaceService"
end
while not game:FindFirstChild "CoreGui" do
wait(0.1)
@ -138,7 +141,7 @@ function closePurchasePrompt()
)
end
function userPurchaseActionsEnded(isSuccess)
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
@ -527,7 +530,7 @@ end
---------------------------------------------- Currency Functions ---------------------------------------------
-- enums have no implicit conversion to numbers in lua, has to have a function to do this
function currencyEnumToInt(currencyEnum)
function currencyEnumToInt(currencyEnum: Enum.CurrencyType)
if
currencyEnum == Enum.CurrencyType.Robux
or currencyEnum == Enum.CurrencyType.Default

View File

@ -1,6 +1,7 @@
print "[Mercury]: Loaded corescript 157877000"
--Include
local Create = assert(LoadLibrary "RbxUtility").Create
local Create: (instance: string) -> ({ [string]: any }) -> Instance =
assert(LoadLibrary "RbxUtility").Create
-- A Few Script Globals
local gui

View File

@ -787,7 +787,7 @@ t.LayoutGuiObjects = function(frame, guiObjects, settingsTable)
frame.Changed:connect(function(prop)
if prop == "AbsoluteSize" then
--Wait a heartbeat for it to sync in
recalculate(nil)
recalculate()
end
end)
frame.AncestryChanged:connect(recalculate)
@ -1914,12 +1914,12 @@ t.CreateScrollingFrame = function(orderList, scrollStyle)
if scrollPosition < 1 then
scrollPosition = 1
end
recalculate(nil)
recalculate()
end
local doScrollDown = function()
scrollPosition += rowSize
recalculate(nil)
recalculate()
end
local scrollUp = function(mouseYPos)
@ -2036,7 +2036,7 @@ t.CreateScrollingFrame = function(orderList, scrollStyle)
end
scrollPosition = newScrollPosition
recalculate(nil)
recalculate()
end)
upCon = mouseDrag.MouseButton1Up:connect(function()
scrollStamp = tick()
@ -2078,21 +2078,21 @@ t.CreateScrollingFrame = function(orderList, scrollStyle)
end)
frame.ChildAdded:connect(function()
recalculate(nil)
recalculate()
end)
frame.ChildRemoved:connect(function()
recalculate(nil)
recalculate()
end)
frame.Changed:connect(function(prop)
if prop == "AbsoluteSize" then
--Wait a heartbeat for it to sync in
recalculate(nil)
recalculate()
end
end)
frame.AncestryChanged:connect(function()
recalculate(nil)
recalculate()
end)
return frame, scrollUpButton, scrollDownButton, recalculate, scrollbar
@ -4017,12 +4017,12 @@ t.CreateLoadingFrame = function(name, size, position)
cancelButtonClicked:Fire()
end)
local updateLoadingGuiPercent = function(percent, tweenAction, tweenLength)
local updateLoadingGuiPercent = function(percent: number, tweenAction, tweenLength)
if percent and type(percent) ~= "number" then
error(
"updateLoadingGuiPercent expects number as argument, got",
type(percent),
"instead"
"updateLoadingGuiPercent expects number as argument, got "
.. type(percent)
.. " instead"
)
end

View File

@ -1639,7 +1639,7 @@ if LoadLibrary then
end
)
function localPlayerChange()
local function localPlayerChange()
gameMainMenu.ResetButton.Visible = game.Players.LocalPlayer
if game.Players.LocalPlayer then
settings().Rendering.EnableFRM = true

View File

@ -1,4 +1,7 @@
print "[Mercury]: Loaded corescript 48488398"
local TeleportService = TeleportService
function waitForProperty(instance, property)
while not instance[property] do
instance.Changed:wait()
@ -183,7 +186,7 @@ function showTeleportUI(message, timer)
end
function onTeleport(teleportState, _, _)
if game:GetService("TeleportService").CustomizedTeleportUI == false then
if TeleportService.CustomizedTeleportUI == false then
if teleportState == Enum.TeleportState.Started then
showTeleportUI("Teleport started...", 0)
elseif teleportState == Enum.TeleportState.WaitingForServer then
@ -202,13 +205,13 @@ end
if teleportEnabled then
localPlayer.OnTeleport:connect(onTeleport)
game:GetService("TeleportService").ErrorCallback = function(message)
TeleportService.ErrorCallback = function(message)
local popup = script.Parent:FindFirstChild "Popup"
showOneButton()
popup.PopupText.Text = message
local clickCon
clickCon = popup.OKButton.MouseButton1Click:connect(function()
game:GetService("TeleportService"):TeleportCancel()
TeleportService:TeleportCancel()
if clickCon then
clickCon:disconnect()
end
@ -252,11 +255,7 @@ if teleportEnabled then
end
)
end
game:GetService("TeleportService").ConfirmationCallback = function(
message,
placeId,
spawnName
)
TeleportService.ConfirmationCallback = function(message, placeId, spawnName)
local popup = script.Parent:FindFirstChild "Popup"
popup.PopupText.Text = message
popup.PopupImage.Image = ""
@ -286,8 +285,7 @@ if teleportEnabled then
yesCon = popup.AcceptButton.MouseButton1Click:connect(function()
killCons()
local success, err = pcall(function()
game:GetService("TeleportService")
:TeleportImpl(placeId, spawnName)
TeleportService:TeleportImpl(placeId, spawnName)
end)
if not success then
showOneButton()
@ -342,7 +340,7 @@ if teleportEnabled then
noCon = popup.DeclineButton.MouseButton1Click:connect(function()
killCons()
pcall(function()
game:GetService("TeleportService"):TeleportCancel()
TeleportService:TeleportCancel()
end)
end)

View File

@ -6,6 +6,9 @@ if game.CoreGui.Version < 3 then
return
end -- peace out if we aren't using the right client
local ContentProvider = game:GetService "ContentProvider"
local UserInputService = game:GetService "UserInputService"
local gui = script.Parent
-- A couple of necessary functions
@ -23,7 +26,7 @@ end
local function IsTouchDevice()
local touchEnabled = false
pcall(function()
touchEnabled = Game:GetService("UserInputService").TouchEnabled
touchEnabled = UserInputService.TouchEnabled
end)
return touchEnabled
end
@ -334,8 +337,7 @@ closeButton.Modal = true
local XImage = Instance.new "ImageLabel"
XImage.RobloxLocked = true
XImage.Name = "XImage"
game:GetService("ContentProvider")
:Preload "http://banland.xyz/asset/?id=75547445"
ContentProvider:Preload "http://banland.xyz/asset/?id=75547445"
XImage.Image = "http://banland.xyz/asset/?id=75547445" --TODO: move to rbxasset
XImage.BackgroundTransparency = 1
XImage.Position = UDim2.new(-0.25, -1, -0.25, -1)
@ -767,8 +769,7 @@ CharacterPane.Parent = Wardrobe
--CharacterPane Children
local FaceFrame = makeCharFrame("FacesFrame", CharacterPane)
game:GetService("ContentProvider")
:Preload "http://banland.xyz/asset/?id=75460621"
ContentProvider:Preload "http://banland.xyz/asset/?id=75460621"
makeZone(
"FaceZone",
"http://banland.xyz/asset/?id=75460621",
@ -799,8 +800,7 @@ makeStyledButton(
)
local HatsFrame = makeCharFrame("HatsFrame", CharacterPane)
game:GetService("ContentProvider")
:Preload "http://banland.xyz/asset/?id=75457888"
ContentProvider:Preload "http://banland.xyz/asset/?id=75457888"
local HatsZone = makeZone(
"HatsZone",
"http://banland.xyz/asset/?id=75457888",
@ -831,8 +831,7 @@ makeStyledButton(
)
local PantsFrame = makeCharFrame("PantsFrame", CharacterPane)
game:GetService("ContentProvider")
:Preload "http://banland.xyz/asset/?id=75457920"
ContentProvider:Preload "http://banland.xyz/asset/?id=75457920"
makeZone(
"PantsZone",
"http://banland.xyz/asset/?id=75457920",
@ -927,8 +926,7 @@ makeTextLabel(
)
local TShirtFrame = makeCharFrame("T-ShirtsFrame", CharacterPane)
game:GetService("ContentProvider")
:Preload "http://banland.xyz/asset/?id=75460642"
ContentProvider:Preload "http://banland.xyz/asset/?id=75460642"
makeZone(
"TShirtZone",
"http://banland.xyz/asset/?id=75460642",
@ -959,8 +957,7 @@ makeStyledButton(
)
local ColorFrame = makeCharFrame("ColorFrame", CharacterPane)
game:GetService("ContentProvider")
:Preload "http://banland.xyz/asset/?id=76049888"
ContentProvider:Preload "http://banland.xyz/asset/?id=76049888"
local ColorZone = makeZone(
"ColorZone",
"http://banland.xyz/asset/?id=76049888",

View File

@ -22,6 +22,8 @@ local backpackEnabled = true
local robloxGui = game:GetService("CoreGui"):FindFirstChild "RobloxGui"
assert(robloxGui)
local GuiService = game:GetService "GuiService"
local controlFrame = waitForChild(robloxGui, "ControlFrame")
local backpackButton = waitForChild(controlFrame, "BackpackButton")
local backpack = waitForChild(robloxGui, "Backpack")
@ -133,14 +135,14 @@ end
function registerNumberKeys()
for i = 0, 9 do
game:GetService("GuiService"):AddKey(tostring(i))
GuiService:AddKey(tostring(i))
end
end
function unregisterNumberKeys()
pcall(function()
for i = 0, 9 do
game:GetService("GuiService"):RemoveKey(tostring(i))
GuiService:RemoveKey(tostring(i))
end
end)
end
@ -1227,6 +1229,7 @@ characterChildAddedCon = player.Character.ChildAdded:connect(function(child)
end)
waitForChild(player.Character, "Humanoid")
local humanoidDiedCon
humanoidDiedCon = player.Character.Humanoid.Died:connect(function()
if humanoidDiedCon then
humanoidDiedCon:disconnect()
@ -1348,7 +1351,7 @@ guiBackpack.SwapSlot.Changed:connect(function()
end
end)
game:GetService("GuiService").KeyPressed:connect(function(key)
GuiService.KeyPressed:connect(function(key)
if characterInWorkspace() then
activateGear(key)
end

View File

@ -520,16 +520,16 @@ t.SelectTerrainRegion = function(
assert(regionToSelect)
assert(color)
if not type(regionToSelect) == "Region3" then
if type(regionToSelect) ~= "Region3" then
error(
"regionToSelect (first arg), should be of type Region3, but is type",
type(regionToSelect)
"regionToSelect (first arg), should be of type Region3, but is type "
.. type(regionToSelect)
)
end
if not type(color) == "BrickColor" then
if type(color) ~= "BrickColor" then
error(
"color (second arg), should be of type BrickColor, but is type",
type(color)
"color (second arg), should be of type BrickColor, but is type "
.. type(color)
)
end
@ -581,7 +581,7 @@ t.SelectTerrainRegion = function(
-- end
-- helper function that creates the basis for a selection box
function createAdornment(theColor)
local function createAdornment(theColor)
local selectionPartClone
local selectionBoxClone

View File

@ -1,4 +1,7 @@
print "[Mercury]: Loaded corescript 73157242"
local ChangeHistoryService = game:GetService "ChangeHistoryService"
local t = {}
-- function waitForChild(instance, name)
@ -1106,7 +1109,7 @@ t.SetupStamperDragger = function(
local function DoHighScalabilityRegionSelect()
local megaCube = stampData.CurrentParts:FindFirstChild "MegaClusterCube"
if not megaCube then
if not stampData.CurrentParts.Name == "MegaClusterCube" then
if stampData.CurrentParts.Name ~= "MegaClusterCube" then
return
else
megaCube = stampData.CurrentParts
@ -1253,9 +1256,9 @@ t.SetupStamperDragger = function(
end
if not Mouse:IsA "Mouse" then
error(
"Error: RbxStamper.DoStamperMouseMove: Mouse is of type",
Mouse.className,
"should be of type Mouse"
"Error: RbxStamper.DoStamperMouseMove: Mouse is of type "
.. Mouse.className
.. " should be of type Mouse"
)
return
end
@ -2229,8 +2232,7 @@ t.SetupStamperDragger = function(
if cellSet then
stampData.CurrentParts.Parent = nil
pcall(function()
game:GetService("ChangeHistoryService")
:SetWaypoint "StamperMulti"
ChangeHistoryService:SetWaypoint "StamperMulti"
end)
end
@ -2529,8 +2531,7 @@ t.SetupStamperDragger = function(
-- Mark for undo. It has to happen here or the selection display will come back also.
pcall(function()
game:GetService("ChangeHistoryService")
:SetWaypoint "StamperSingle"
ChangeHistoryService:SetWaypoint "StamperSingle"
end)
return true
end
@ -2688,7 +2689,7 @@ t.SetupStamperDragger = function(
stampData.CurrentParts = nil
pcall(function()
game:GetService("ChangeHistoryService"):SetWaypoint "StampedObject"
ChangeHistoryService:SetWaypoint "StampedObject"
end)
return true
end

View File

@ -4,6 +4,8 @@ if game.CoreGui.Version < 7 then
return
end -- peace out if we aren't using the right client
local GuiService = game:GetService "GuiService"
-- basic functions
local function waitForChild(instance, name)
while not instance:FindFirstChild(name) do
@ -395,12 +397,12 @@ function coreGuiChanged(coreGuiType, enabled)
if disabledByDeveloper then
pcall(function()
game:GetService("GuiService"):RemoveKey(tilde)
game:GetService("GuiService"):RemoveKey(backquote)
GuiService:RemoveKey(tilde)
GuiService:RemoveKey(backquote)
end)
else
game:GetService("GuiService"):AddKey(tilde)
game:GetService("GuiService"):AddKey(backquote)
GuiService:AddKey(tilde)
GuiService:AddKey(backquote)
end
resetSearch()
@ -460,9 +462,9 @@ screen.Changed:connect(function(prop)
end)
-- GuiService key setup
game:GetService("GuiService"):AddKey(tilde)
game:GetService("GuiService"):AddKey(backquote)
game:GetService("GuiService").KeyPressed:connect(function(key)
GuiService:AddKey(tilde)
GuiService:AddKey(backquote)
GuiService.KeyPressed:connect(function(key)
if not active or disabledByDeveloper then
return
end

View File

@ -1690,7 +1690,7 @@ function Input:OnMouseScroll()
if Chat:CheckIfInBounds(Input.Speed) then
return
end
Chat:ScrollQueue()
-- Chat:ScrollQueue()
end
function Input:ApplySpeed(value)

View File

@ -2,6 +2,10 @@ print "[Mercury]: Loaded Host corescript"
-- Start Game Script Arguments
local placeId, sleeptime, access, url, killID, deathID, timeout, injectScriptAssetID, servicesUrl, libraryRegistrationScriptAssetID
local InsertService = game:GetService "InsertService"
local BadgeService = game:GetService "BadgeService"
local FriendService = game:GetService "FriendService"
-- StartGame --
pcall(function()
game:GetService("ScriptContext"):AddStarterScript(injectScriptAssetID)
@ -112,48 +116,48 @@ if url ~= nil then
end)
-- pcall(function() game:GetService("Players"):SetChatFilterUrl(url .. "/Game/ChatFilter.ashx") end)
-- game:GetService("BadgeService"):SetPlaceId(placeId)
-- BadgeService:SetPlaceId(placeId)
if access ~= nil then
game:GetService("BadgeService"):SetAwardBadgeUrl(
BadgeService:SetAwardBadgeUrl(
url
.. "/Game/Badge/AwardBadge.ashx?UserID=%d&BadgeID=%d&PlaceID=%d&"
.. access
)
game:GetService("BadgeService"):SetHasBadgeUrl(
BadgeService:SetHasBadgeUrl(
url .. "/Game/Badge/HasBadge.ashx?UserID=%d&BadgeID=%d&" .. access
)
game:GetService("BadgeService"):SetIsBadgeDisabledUrl(
BadgeService:SetIsBadgeDisabledUrl(
url
.. "/Game/Badge/IsBadgeDisabled.ashx?BadgeID=%d&PlaceID=%d&"
.. access
)
game:GetService("FriendService"):SetMakeFriendUrl(
FriendService:SetMakeFriendUrl(
servicesUrl
.. "/Friend/CreateFriend?firstUserId=%d&secondUserId=%d&"
.. access
)
game:GetService("FriendService"):SetBreakFriendUrl(
FriendService:SetBreakFriendUrl(
servicesUrl
.. "/Friend/BreakFriend?firstUserId=%d&secondUserId=%d&"
.. access
)
game:GetService("FriendService"):SetGetFriendsUrl(
FriendService:SetGetFriendsUrl(
servicesUrl .. "/Friend/AreFriends?userId=%d&" .. access
)
end
game:GetService("BadgeService"):SetIsBadgeLegalUrl ""
game:GetService("InsertService")
BadgeService:SetIsBadgeLegalUrl ""
InsertService
:SetBaseSetsUrl(
url .. "/Game/Tools/InsertAsset.ashx?nsets=10&type=base"
)
game:GetService("InsertService"):SetUserSetsUrl(
InsertService:SetUserSetsUrl(
url .. "/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d"
)
game:GetService("InsertService")
InsertService
:SetCollectionUrl(url .. "/Game/Tools/InsertAsset.ashx?sid=%d")
game:GetService("InsertService"):SetAssetUrl(url .. "/Asset/?id=%d")
game:GetService("InsertService")
InsertService:SetAssetUrl(url .. "/Asset/?id=%d")
InsertService
:SetAssetVersionUrl(url .. "/Asset/?assetversionid=%d")
pcall(function()

View File

@ -88,7 +88,7 @@ pcall(function()
Players:SetChatStyle(Enum.ChatStyle.ClassicAndBubble)
end)
local waitingForCharacter = false
waitingForCharacter = false
pcall(function()
if settings().Network.MtuOverride == 0 then
settings().Network.MtuOverride = 1400
@ -96,7 +96,7 @@ pcall(function()
end)
-- functions ---------------------------------------
function setMessage(message)
function setMessage(message: string)
-- todo: animated "..."
game:SetMessage(message)
end
@ -241,7 +241,7 @@ local success, err = pcall(function()
connectionFailed = Client.ConnectionFailed:connect(onConnectionFailed)
Client.Ticket = ""
playerConnectSucces, player = pcall(function()
local playerConnectSuccess, player = pcall(function()
return Client:PlayerConnect(
_USER_ID,
"_SERVER_ADDRESS",
@ -250,7 +250,7 @@ local success, err = pcall(function()
threadSleepTime
)
end)
if not playerConnectSucces then
if not playerConnectSuccess then
--Old player connection scheme
player = Players:CreateLocalPlayer(_USER_ID)
Client:Connect("_SERVER_ADDRESS", _SERVER_PORT, 0, threadSleepTime)

View File

@ -122,7 +122,7 @@ function doVisit()
end)
end
success, err = pcall(doVisit)
local success, err = pcall(doVisit)
if not addedBuildTools then
local playerName = Instance.new "StringValue"

View File

@ -235,6 +235,12 @@ globals:
type: number
- required: false
type: number
Enum.UploadSetting.Never:
struct: EnumItem
Enum.PriorityMethod.Ask me first:
struct: EnumItem
Enum.PriorityMethod.AccumulatedError:
struct: EnumItem
Enum.PhysicsSendMethod.ErrorComputation2:
@ -5586,6 +5592,10 @@ globals:
math.sign:
args:
- type: number
math.nan:
property: read-only
math.inf:
property: read-only
module:
removed: true
os.execute:
@ -6939,6 +6949,9 @@ structs:
args:
- required: false
type: any
SetMessageBrickCount:
method: true
args: []
GetService:
args:
- type: