Clean up some yuescript syntax in corescripts

This commit is contained in:
Lewin Kelly 2023-04-19 11:18:02 +01:00
parent fb57c2199f
commit a98951aca6
10 changed files with 40 additions and 50 deletions

View File

@ -32,16 +32,6 @@ local t = {}
--CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN --CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
--CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local string = string
local math = math
local table = table
local error = error
local tonumber = tonumber
local tostring = tostring
local type = type
local setmetatable = setmetatable
local pairs = pairs
local ipairs = ipairs
local assert = assert local assert = assert
local StringBuilder = { local StringBuilder = {

View File

@ -29,7 +29,7 @@ New = (className, name, props) ->
-- Variables -- Variables
contextActionService = Game\GetService "ContextActionService" contextActionService = Game\GetService "ContextActionService"
isTouchDevice = Game\GetService("UserInputService").TouchEnabled isTouchDevice = Game\GetService"UserInputService".TouchEnabled
functionTable = {} functionTable = {}
buttonVector = {} buttonVector = {}
local buttonScreenGui local buttonScreenGui
@ -99,7 +99,7 @@ contextButtonUp = (button, inputObject, actionName) ->
contextActionService\CallFunction actionName, Enum.UserInputState.End, inputObject contextActionService\CallFunction actionName, Enum.UserInputState.End, inputObject
isSmallScreenDevice = -> isSmallScreenDevice = ->
Game\GetService("GuiService")\GetScreenResolution!.y <= 320 Game\GetService"GuiService"\GetScreenResolution!.y <= 320
createNewButton = (actionName, functionInfoTable) -> createNewButton = (actionName, functionInfoTable) ->
contextButton = New "ImageButton", "ContextActionButton" contextButton = New "ImageButton", "ContextActionButton"
@ -114,7 +114,7 @@ createNewButton = (actionName, functionInfoTable) ->
local currentButtonTouch local currentButtonTouch
Game\GetService("UserInputService").InputEnded\connect (inputObject) -> Game\GetService"UserInputService".InputEnded\connect (inputObject) ->
oldTouches[inputObject] = nil oldTouches[inputObject] = nil
contextButton.InputBegan\connect (inputObject) -> contextButton.InputBegan\connect (inputObject) ->

View File

@ -44,7 +44,7 @@ if not success
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- Variables -- Variables
screenResolution = Game\GetService("GuiService")\GetScreenResolution! screenResolution = Game\GetService"GuiService"\GetScreenResolution!
isSmallScreenDevice = -> isSmallScreenDevice = ->
return screenResolution.y <= 320 return screenResolution.y <= 320
@ -74,7 +74,7 @@ PinchZoomDelay = 0.2
local cameraTouch local cameraTouch
-- make sure all of our images are good to go -- make sure all of our images are good to go
Game\GetService("ContentProvider")\Preload touchControlsSheet Game\GetService"ContentProvider"\Preload touchControlsSheet
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
---------------------------------------------------------------------------- ----------------------------------------------------------------------------

View File

@ -107,7 +107,7 @@ for i = 1, #bottomLeftChildren
bottomRightChildren = bottomRightControl\GetChildren! bottomRightChildren = bottomRightControl\GetChildren!
for i = 1, #bottomRightChildren for i = 1, #bottomRightChildren
if bottomRightChildren[i].Name\find("Camera")? if bottomRightChildren[i].Name\find"Camera"?
with cameraTip = frameTip\clone! with cameraTip = frameTip\clone!
.RobloxLocked = true .RobloxLocked = true
.Text = "Camera View" .Text = "Camera View"

View File

@ -6,7 +6,7 @@ scriptContext = game\GetService "ScriptContext"
touchEnabled = false touchEnabled = false
try try
touchEnabled = game\GetService("UserInputService").TouchEnabled touchEnabled = game\GetService"UserInputService".TouchEnabled
-- library registration -- library registration
scriptContext\AddCoreScript 60595695, scriptContext, "/Libraries/LibraryRegistration/LibraryRegistration" scriptContext\AddCoreScript 60595695, scriptContext, "/Libraries/LibraryRegistration/LibraryRegistration"
@ -23,8 +23,8 @@ waitForChild = (instance, name) ->
scriptContext = game\GetService "ScriptContext" scriptContext = game\GetService "ScriptContext"
scriptContext\AddCoreScript 59002209, scriptContext, "CoreScripts/Sections" scriptContext\AddCoreScript 59002209, scriptContext, "CoreScripts/Sections"
waitForChild game\GetService("CoreGui"), "RobloxGui" waitForChild game\GetService"CoreGui", "RobloxGui"
screenGui = game\GetService("CoreGui")\FindFirstChild "RobloxGui" screenGui = game\GetService"CoreGui"\FindFirstChild "RobloxGui"
if not touchEnabled if not touchEnabled
-- ToolTipper (creates tool tips for gui) -- ToolTipper (creates tool tips for gui)

View File

@ -186,7 +186,7 @@ while true
table.insert backpackTools, currentChildren[i] table.insert backpackTools, currentChildren[i]
for i = 1, #backpackTools for i = 1, #backpackTools
if not backpackTools[i]\FindFirstChild("RobloxBuildTool")? if not backpackTools[i]\FindFirstChild"RobloxBuildTool"?
hider\Clone!.Parent = backpackTools[i] hider\Clone!.Parent = backpackTools[i]
backpackTools[i].Parent = game.Lighting backpackTools[i].Parent = game.Lighting

View File

@ -464,10 +464,10 @@ addDialog = (dialog) ->
addDialog dialog addDialog dialog
fetchScripts = -> fetchScripts = ->
model = game\GetService("InsertService")\LoadAsset 39226062 model = game\GetService"InsertService"\LoadAsset 39226062
if type(model) == "string" -- load failed, lets try again if type(model) == "string" -- load failed, lets try again
wait 0.1 wait 0.1
model = game\GetService("InsertService")\LoadAsset 39226062 model = game\GetService"InsertService"\LoadAsset 39226062
return if type(model) == "string" -- not going to work, lets bail return if type(model) == "string" -- not going to work, lets bail
waitForChild model, "TimeoutScript" waitForChild model, "TimeoutScript"

View File

@ -1686,7 +1686,7 @@ binaryShrink = (min, max, fits) ->
getGuiOwner = (instance) -> getGuiOwner = (instance) ->
while instance? while instance?
if instance\IsA("ScreenGui") or instance\IsA("BillboardGui") if instance\IsA"ScreenGui" or instance\IsA"BillboardGui"
return instance return instance
instance = instance.Parent instance = instance.Parent
@ -2133,7 +2133,7 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position
buttonHeight = buttonWidth buttonHeight = buttonWidth
local SmallThumbnailUrl, LargeThumbnailUrl local SmallThumbnailUrl, LargeThumbnailUrl
BaseUrl = game\GetService("ContentProvider").BaseUrl\lower! BaseUrl = game\GetService"ContentProvider".BaseUrl\lower!
LargeThumbnailUrl, SmallThumbnailUrl = if useAssetVersionId LargeThumbnailUrl, SmallThumbnailUrl = if useAssetVersionId
"#{BaseUrl}Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=420&ht=420&assetversionid=", "#{BaseUrl}Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=75&ht=75&assetversionid=" "#{BaseUrl}Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=420&ht=420&assetversionid=", "#{BaseUrl}Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=75&ht=75&assetversionid="
@ -2410,7 +2410,7 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position
showLargePreview = (insertButton) -> showLargePreview = (insertButton) ->
if insertButton\FindFirstChild "AssetId" if insertButton\FindFirstChild "AssetId"
delay 0, -> delay 0, ->
game\GetService("ContentProvider")\Preload LargeThumbnailUrl .. "#{insertButton.AssetId.Value}" game\GetService"ContentProvider"\Preload LargeThumbnailUrl .. "#{insertButton.AssetId.Value}"
setGui.SetPanel.ItemPreview.LargePreview.Image = LargeThumbnailUrl .. "#{insertButton.AssetId.Value}" setGui.SetPanel.ItemPreview.LargePreview.Image = LargeThumbnailUrl .. "#{insertButton.AssetId.Value}"
if insertButton\FindFirstChild "AssetName" if insertButton\FindFirstChild "AssetName"
@ -2526,7 +2526,7 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position
newImageUrl = SmallThumbnailUrl .. assetId newImageUrl = SmallThumbnailUrl .. assetId
if newImageUrl ~= insertFrame.Button.ButtonImage.Image if newImageUrl ~= insertFrame.Button.ButtonImage.Image
delay 0, -> delay 0, ->
game\GetService("ContentProvider")\Preload(SmallThumbnailUrl .. assetId) game\GetService"ContentProvider"\Preload(SmallThumbnailUrl .. assetId)
insertFrame.Button.ButtonImage.Image = SmallThumbnailUrl .. assetId insertFrame.Button.ButtonImage.Image = SmallThumbnailUrl .. assetId
table.insert( table.insert(
@ -2616,7 +2616,7 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position
.Button = button .Button = button
if not SetCache[setId]? if not SetCache[setId]?
SetCache[setId] = game\GetService("InsertService")\GetCollection setId SetCache[setId] = game\GetService"InsertService"\GetCollection setId
.Contents = SetCache[setId] .Contents = SetCache[setId]
.SetName = setName .SetName = setName
@ -2739,7 +2739,7 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position
userData = {} userData = {}
for id = 1, #userIdsForSets for id = 1, #userIdsForSets
newUserData = game\GetService("InsertService")\GetUserSets userIdsForSets[id] newUserData = game\GetService"InsertService"\GetUserSets userIdsForSets[id]
if newUserData and #newUserData > 2 if newUserData and #newUserData > 2
-- start at #3 to skip over My Decals and My Models for each account -- start at #3 to skip over My Decals and My Models for each account
for category = 3, #newUserData for category = 3, #newUserData
@ -2949,7 +2949,7 @@ t.CreateTerrainMaterialSelector = (size, position) ->
frame, terrainMaterialSelectionChanged, forceTerrainMaterialSelection frame, terrainMaterialSelectionChanged, forceTerrainMaterialSelection
t.CreateLoadingFrame = (name, size, position) -> t.CreateLoadingFrame = (name, size, position) ->
game\GetService("ContentProvider")\Preload "http://www.roblox.com/asset/?id=35238053" game\GetService"ContentProvider"\Preload "http://www.roblox.com/asset/?id=35238053"
loadingFrame = New "Frame", "LoadingFrame" loadingFrame = New "Frame", "LoadingFrame"
Style: Enum.FrameStyle.RobloxRound Style: Enum.FrameStyle.RobloxRound
@ -3270,7 +3270,7 @@ t.CreatePluginFrame = (name, size, position, scrollable, parent) ->
size.Y.Scale, size.Y.Offset size.Y.Scale, size.Y.Offset
else else
0, 400 0, 400
\FindFirstChild("ScrollDownButton").Position = UDim2.new 0, 0, 1, -20 \FindFirstChild"ScrollDownButton".Position = UDim2.new 0, 0, 1, -20
.Parent = dragBar .Parent = dragBar

View File

@ -94,7 +94,7 @@ game.Players.FriendRequestEvent\connect (fromPlayer, toPlayer, event) ->
if fromPlayer == localPlayer if fromPlayer == localPlayer
if event == Enum.FriendRequestEvent.Accept if event == Enum.FriendRequestEvent.Accept
game\GetService("GuiService")\SendNotification( game\GetService"GuiService"\SendNotification(
"You are Friends", "You are Friends",
"With #{toPlayer.Name}!", "With #{toPlayer.Name}!",
"http://www.roblox.com/thumbs/avatar.ashx?userId=#{toPlayer.userId}&x=48&y=48", "http://www.roblox.com/thumbs/avatar.ashx?userId=#{toPlayer.userId}&x=48&y=48",
@ -106,7 +106,7 @@ game.Players.FriendRequestEvent\connect (fromPlayer, toPlayer, event) ->
if friendRequestBlacklist[fromPlayer] if friendRequestBlacklist[fromPlayer]
return return
-- previously cancelled friend request, we don't want it! -- previously cancelled friend request, we don't want it!
game\GetService("GuiService")\SendNotification( game\GetService"GuiService"\SendNotification(
"Friend Request", "Friend Request",
"From #{fromPlayer.Name}", "From #{fromPlayer.Name}",
"http://www.roblox.com/thumbs/avatar.ashx?userId=#{fromPlayer.userId}&x=48&y=48", "http://www.roblox.com/thumbs/avatar.ashx?userId=#{fromPlayer.userId}&x=48&y=48",
@ -114,7 +114,7 @@ game.Players.FriendRequestEvent\connect (fromPlayer, toPlayer, event) ->
-> makeFriend fromPlayer, toPlayer -> makeFriend fromPlayer, toPlayer
) )
elseif event == Enum.FriendRequestEvent.Accept elseif event == Enum.FriendRequestEvent.Accept
game\GetService("GuiService")\SendNotification( game\GetService"GuiService"\SendNotification(
"You are Friends", "You are Friends",
"With #{fromPlayer.Name}!", "With #{fromPlayer.Name}!",
"http://www.roblox.com/thumbs/avatar.ashx?userId=#{fromPlayer.userId}&x=48&y=48", "http://www.roblox.com/thumbs/avatar.ashx?userId=#{fromPlayer.userId}&x=48&y=48",
@ -135,7 +135,7 @@ showTeleportUI = (message, timer) ->
\Remove! \Remove!
onTeleport = (teleportState, _, _) -> onTeleport = (teleportState, _, _) ->
if game\GetService("TeleportService").CustomizedTeleportUI == false if game\GetService"TeleportService".CustomizedTeleportUI == false
showTeleportUI switch teleportState showTeleportUI switch teleportState
when Enum.TeleportState.Started when Enum.TeleportState.Started
"Teleport started...", 0 "Teleport started...", 0
@ -149,13 +149,13 @@ onTeleport = (teleportState, _, _) ->
if teleportEnabled if teleportEnabled
localPlayer.OnTeleport\connect onTeleport localPlayer.OnTeleport\connect onTeleport
game\GetService("TeleportService").ErrorCallback = (message) -> game\GetService"TeleportService".ErrorCallback = (message) ->
popup = script.Parent\FindFirstChild "Popup" popup = script.Parent\FindFirstChild "Popup"
showOneButton! showOneButton!
popup.PopupText.Text = message popup.PopupText.Text = message
local clickCon local clickCon
clickCon = popup.OKButton.MouseButton1Click\connect -> clickCon = popup.OKButton.MouseButton1Click\connect ->
game\GetService("TeleportService")\TeleportCancel! game\GetService"TeleportService"\TeleportCancel!
if clickCon if clickCon
clickCon\disconnect! clickCon\disconnect!
game.GuiService\RemoveCenterDialog script.Parent\FindFirstChild "Popup" game.GuiService\RemoveCenterDialog script.Parent\FindFirstChild "Popup"
@ -173,7 +173,7 @@ if teleportEnabled
--ShowFunction --ShowFunction
-> ->
showOneButton! showOneButton!
script.Parent\FindFirstChild("Popup").Visible = true script.Parent\FindFirstChild"Popup".Visible = true
popup\TweenSize UDim2.new(0, 330, 0, 350), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true popup\TweenSize UDim2.new(0, 330, 0, 350), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true
--HideFunction --HideFunction
-> ->
@ -186,7 +186,7 @@ if teleportEnabled
makePopupInvisible! makePopupInvisible!
) )
) )
game\GetService("TeleportService").ConfirmationCallback = (message, placeId, spawnName) -> game\GetService"TeleportService".ConfirmationCallback = (message, placeId, spawnName) ->
popup = script.Parent\FindFirstChild "Popup" popup = script.Parent\FindFirstChild "Popup"
popup.PopupText.Text = message popup.PopupText.Text = message
popup.PopupImage.Image = "" popup.PopupImage.Image = ""
@ -210,7 +210,7 @@ if teleportEnabled
yesCon = popup.AcceptButton.MouseButton1Click\connect -> yesCon = popup.AcceptButton.MouseButton1Click\connect ->
killCons! killCons!
local success, err = try local success, err = try
game\GetService("TeleportService")\TeleportImpl placeId, spawnName game\GetService"TeleportService"\TeleportImpl placeId, spawnName
if not success if not success
showOneButton! showOneButton!
popup.PopupText.Text = err popup.PopupText.Text = err
@ -231,7 +231,7 @@ if teleportEnabled
--ShowFunction --ShowFunction
-> ->
showOneButton! showOneButton!
script.Parent\FindFirstChild("Popup").Visible = true script.Parent\FindFirstChild"Popup".Visible = true
popup\TweenSize( popup\TweenSize(
UDim2.new(0, 330, 0, 350), UDim2.new(0, 330, 0, 350),
Enum.EasingDirection.Out, Enum.EasingDirection.Out,
@ -254,7 +254,7 @@ if teleportEnabled
noCon = popup.DeclineButton.MouseButton1Click\connect -> noCon = popup.DeclineButton.MouseButton1Click\connect ->
killCons! killCons!
try try
game\GetService("TeleportService")\TeleportCancel! game\GetService"TeleportService"\TeleportCancel!
centerDialogSuccess = try centerDialogSuccess = try
game.GuiService\AddCenterDialog( game.GuiService\AddCenterDialog(
@ -265,7 +265,7 @@ if teleportEnabled
showTwoButtons! showTwoButtons!
popup.AcceptButton.Text = "Leave" popup.AcceptButton.Text = "Leave"
popup.DeclineButton.Text = "Stay" popup.DeclineButton.Text = "Stay"
script.Parent\FindFirstChild("Popup").Visible = true script.Parent\FindFirstChild"Popup".Visible = true
popup\TweenSize( popup\TweenSize(
UDim2.new(0, 330, 0, 350), UDim2.new(0, 330, 0, 350),
Enum.EasingDirection.Out, Enum.EasingDirection.Out,
@ -286,7 +286,7 @@ if teleportEnabled
) )
if centerDialogSuccess == false if centerDialogSuccess == false
script.Parent\FindFirstChild("Popup").Visible = true script.Parent\FindFirstChild"Popup".Visible = true
popup.AcceptButton.Text = "Leave" popup.AcceptButton.Text = "Leave"
popup.DeclineButton.Text = "Stay" popup.DeclineButton.Text = "Stay"
popup\TweenSize UDim2.new(0, 330, 0, 350), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true popup\TweenSize UDim2.new(0, 330, 0, 350), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 1, true

View File

@ -42,7 +42,7 @@ waitForProperty = (instance, property) ->
IsTouchDevice = -> IsTouchDevice = ->
touchEnabled = false touchEnabled = false
try try
touchEnabled = Game\GetService("UserInputService").TouchEnabled touchEnabled = Game\GetService"UserInputService".TouchEnabled
touchEnabled touchEnabled
IsPhone = -> IsPhone = ->
@ -322,7 +322,7 @@ Tabs = New "Frame", "Tabs"
* New "ImageLabel", "XImage" * New "ImageLabel", "XImage"
RobloxLocked: true RobloxLocked: true
Image: (-> Image: (->
game\GetService("ContentProvider")\Preload "http://www.roblox.com/asset/?id=75547445" game\GetService"ContentProvider"\Preload "http://www.roblox.com/asset/?id=75547445"
"http://www.roblox.com/asset/?id=75547445" "http://www.roblox.com/asset/?id=75547445"
)! --TODO: move to rbxasset )! --TODO: move to rbxasset
BackgroundTransparency: 1 BackgroundTransparency: 1
@ -685,7 +685,7 @@ CharacterPane = New "Frame", "CharacterPane"
--CharacterPane Children --CharacterPane Children
FaceFrame = makeCharFrame "FacesFrame", CharacterPane FaceFrame = makeCharFrame "FacesFrame", CharacterPane
game\GetService("ContentProvider")\Preload "http://www.roblox.com/asset/?id=75460621" game\GetService"ContentProvider"\Preload "http://www.roblox.com/asset/?id=75460621"
makeZone( makeZone(
"FaceZone", "FaceZone",
"http://www.roblox.com/asset/?id=75460621", "http://www.roblox.com/asset/?id=75460621",
@ -706,7 +706,7 @@ makeZone(
makeStyledButton "Head", UDim2.new(0, 64, 0, 64), UDim2.new(0.5, -32, 0.5, -135), HeadFrame makeStyledButton "Head", UDim2.new(0, 64, 0, 64), UDim2.new(0.5, -32, 0.5, -135), HeadFrame
HatsFrame = makeCharFrame "HatsFrame", CharacterPane HatsFrame = makeCharFrame "HatsFrame", CharacterPane
game\GetService("ContentProvider")\Preload "http://www.roblox.com/asset/?id=75457888" game\GetService"ContentProvider"\Preload "http://www.roblox.com/asset/?id=75457888"
HatsZone = makeZone( HatsZone = makeZone(
"HatsZone", "HatsZone",
"http://www.roblox.com/asset/?id=75457888", "http://www.roblox.com/asset/?id=75457888",
@ -737,7 +737,7 @@ makeStyledButton(
) )
PantsFrame = makeCharFrame "PantsFrame", CharacterPane PantsFrame = makeCharFrame "PantsFrame", CharacterPane
game\GetService("ContentProvider")\Preload "http://www.roblox.com/asset/?id=75457920" game\GetService"ContentProvider"\Preload "http://www.roblox.com/asset/?id=75457920"
makeZone( makeZone(
"PantsZone", "PantsZone",
"http://www.roblox.com/asset/?id=75457920", "http://www.roblox.com/asset/?id=75457920",
@ -810,7 +810,7 @@ leftArmButton = makeStyledButton(
makeTextLabel "LeftArmLabel", "Left Arm", UDim2.new(0.5, -16, 0, -25), leftArmButton makeTextLabel "LeftArmLabel", "Left Arm", UDim2.new(0.5, -16, 0, -25), leftArmButton
TShirtFrame = makeCharFrame "T-ShirtsFrame", CharacterPane TShirtFrame = makeCharFrame "T-ShirtsFrame", CharacterPane
game\GetService("ContentProvider")\Preload "http://www.roblox.com/asset/?id=75460642" game\GetService"ContentProvider"\Preload "http://www.roblox.com/asset/?id=75460642"
makeZone( makeZone(
"TShirtZone", "TShirtZone",
"http://www.roblox.com/asset/?id=75460642", "http://www.roblox.com/asset/?id=75460642",
@ -831,7 +831,7 @@ makeZone(
makeStyledButton "ShirtButton", UDim2.new(0, 64, 0, 64), UDim2.new(0.5, -32, 0.5, -64), ShirtFrame makeStyledButton "ShirtButton", UDim2.new(0, 64, 0, 64), UDim2.new(0.5, -32, 0.5, -64), ShirtFrame
ColorFrame = makeCharFrame "ColorFrame", CharacterPane ColorFrame = makeCharFrame "ColorFrame", CharacterPane
game\GetService("ContentProvider")\Preload "http://www.roblox.com/asset/?id=76049888" game\GetService"ContentProvider"\Preload "http://www.roblox.com/asset/?id=76049888"
ColorZone = makeZone( ColorZone = makeZone(
"ColorZone", "ColorZone",
"http://www.roblox.com/asset/?id=76049888", "http://www.roblox.com/asset/?id=76049888",