Further unnecessary definition removal from defs.d.lua file, and other formatting improvements

This commit is contained in:
Lewin Kelly 2024-04-11 14:23:57 +01:00
parent 2b17f25fca
commit 51d5f944e5
8 changed files with 147 additions and 1506 deletions

View File

@ -161,29 +161,49 @@ return function(IsServer: boolean)
-- debug.profileend() -- debug.profileend()
end) end)
else return
Remote.OnServerEvent:connect( end
function(Player, SingleFire, MultipleFire, IncomingCall) Remote.OnServerEvent:connect(
-- debug.profilebegin "Red.Listen.Incoming" function(Player, SingleFire, MultipleFire, IncomingCall)
-- debug.profilebegin "Red.Listen.Incoming"
-- replace nil symbols with nil -- replace nil symbols with nil
if SingleFire.__nil then if SingleFire.__nil then
SingleFire = nil SingleFire = nil
end end
if MultipleFire.__nil then if MultipleFire.__nil then
MultipleFire = nil MultipleFire = nil
end end
if IncomingCall.__nil then if IncomingCall.__nil then
IncomingCall = nil IncomingCall = nil
end
if SingleFire then
-- debug.profilebegin "Red.Listen.Incoming.SingleFire"
for EventId, Call in pairs(SingleFire) do
local Callback = Event.Callbacks[EventId]
if Callback then
if type(Call) == "table" then
Spawn(Callback, Player, unpack(Call))
else
Spawn(Callback, Player, Call)
end
end
end end
if SingleFire then -- debug.profileend()
-- debug.profilebegin "Red.Listen.Incoming.SingleFire" end
for EventId, Call in pairs(SingleFire) do if MultipleFire then
local Callback = Event.Callbacks[EventId] -- debug.profilebegin "Red.Listen.Incoming.MultipleFire"
if Callback then for EventId, Calls in pairs(MultipleFire) do
local Callback = Event.Callbacks[EventId]
if Callback then
for _, Call in ipairs(Calls) do
if type(Call) == "table" then if type(Call) == "table" then
Spawn(Callback, Player, unpack(Call)) Spawn(Callback, Player, unpack(Call))
else else
@ -191,132 +211,112 @@ return function(IsServer: boolean)
end end
end end
end end
-- debug.profileend()
end
if MultipleFire then
-- debug.profilebegin "Red.Listen.Incoming.MultipleFire"
for EventId, Calls in pairs(MultipleFire) do
local Callback = Event.Callbacks[EventId]
if Callback then
for _, Call in ipairs(Calls) do
if type(Call) == "table" then
Spawn(Callback, Player, unpack(Call))
else
Spawn(Callback, Player, Call)
end
end
end
end
-- debug.profileend()
end
if IncomingCall then
-- debug.profilebegin "Red.Listen.Incoming.Call"
for EventId, Calls in pairs(IncomingCall) do
if Event.Callbacks[EventId] then
for _, Call in ipairs(Calls) do
Spawn(function()
local CallId = table.remove(Call, 1)
local Result = {
CallId,
pcall(
Event.Callbacks[EventId],
Player,
unpack(Call)
),
}
if Event.Outgoing[Player] == nil then
Event.Outgoing[Player] = {}
end
if Event.Outgoing[Player][2] == nil then
Event.Outgoing[Player][2] = {}
end
table.insert(
Event.Outgoing[Player][2],
Result
)
end)
end
else
if Event.Outgoing[Player] == nil then
Event.Outgoing[Player] = {}
end
if Event.Outgoing[Player][2] == nil then
Event.Outgoing[Player][2] = {}
end
for _, Call in ipairs(Calls) do
table.insert(Event.Outgoing[Player][2], {
Call[1],
false,
"[Red]: Event not found",
})
end
end
end
-- debug.profileend()
end end
-- debug.profileend() -- debug.profileend()
end end
)
RunService.Heartbeat:connect(function() if IncomingCall then
-- debug.profilebegin "Red.Listen.Outgoing" -- debug.profilebegin "Red.Listen.Incoming.Call"
for Player, Packets in pairs(Event.Outgoing) do for EventId, Calls in pairs(IncomingCall) do
local SingleCall = {} if Event.Callbacks[EventId] then
local SendSingleCall = false for _, Call in ipairs(Calls) do
Spawn(function()
local CallId = table.remove(Call, 1)
local Result = {
CallId,
pcall(
Event.Callbacks[EventId],
Player,
unpack(Call)
),
}
if Packets[1] then if Event.Outgoing[Player] == nil then
for EventId, Calls in pairs(Packets[1]) do Event.Outgoing[Player] = {}
if #Calls == 1 then end
SingleCall[EventId] = Calls[1]
Packets[1][EventId] = nil
SendSingleCall = true if Event.Outgoing[Player][2] == nil then
Event.Outgoing[Player][2] = {}
end
table.insert(
Event.Outgoing[Player][2],
Result
)
end)
end
else
if Event.Outgoing[Player] == nil then
Event.Outgoing[Player] = {}
end
if Event.Outgoing[Player][2] == nil then
Event.Outgoing[Player][2] = {}
end
for _, Call in ipairs(Calls) do
table.insert(Event.Outgoing[Player][2], {
Call[1],
false,
"[Red]: Event not found",
})
end end
end end
end end
-- nils cannot be sent properly across remoteevents in 2013, -- debug.profileend()
-- so we have to use a symbol to represent nil
local sc = nil_symbol
if SendSingleCall then
sc = SingleCall
end
local p1, p2 = Packets[1], Packets[2]
if p1 == nil then
p1 = nil_symbol
end
if p2 == nil then
p2 = nil_symbol
end
Remote:FireClient(Player, sc, p1, p2)
end
-- table.clear(Event.Outgoing)
for i, _ in pairs(Event.Outgoing) do
Event.Outgoing[i] = nil
end end
-- debug.profileend() -- debug.profileend()
end) end
end )
RunService.Heartbeat:connect(function()
-- debug.profilebegin "Red.Listen.Outgoing"
for Player, Packets in pairs(Event.Outgoing) do
local SingleCall = {}
local SendSingleCall = false
if Packets[1] then
for EventId, Calls in pairs(Packets[1]) do
if #Calls == 1 then
SingleCall[EventId] = Calls[1]
Packets[1][EventId] = nil
SendSingleCall = true
end
end
end
-- nils cannot be sent properly across remoteevents in 2013,
-- so we have to use a symbol to represent nil
local sc = nil_symbol
if SendSingleCall then
sc = SingleCall
end
local p1, p2 = Packets[1], Packets[2]
if p1 == nil then
p1 = nil_symbol
end
if p2 == nil then
p2 = nil_symbol
end
Remote:FireClient(Player, sc, p1, p2)
end
-- table.clear(Event.Outgoing)
for i, _ in pairs(Event.Outgoing) do
Event.Outgoing[i] = nil
end
-- debug.profileend()
end)
end end
function Event.AddQueue(Queue: { any }, Call: { any }) function Event.AddQueue(Queue: { any }, Call: { any })

View File

@ -13,11 +13,11 @@ return function()
end, function() end, function()
for _, Item in ipairs(Bin) do for _, Item in ipairs(Bin) do
if typeof(Item) == "Instance" then if typeof(Item) == "Instance" then
Item:Destroy() (Item :: Instance):Destroy()
elseif typeof(Item) == "RBXScriptConnection" then elseif typeof(Item) == "RBXScriptConnection" then
Item:disconnect() (Item :: RBXScriptConnection):disconnect()
elseif typeof(Item) == "function" then elseif typeof(Item) == "function" then
Spawn(Item) Spawn(Item :: () -> ...any)
end end
end end

View File

@ -27,12 +27,12 @@ Clock.new = Clock.Clock
function Clock.Pause(self: Clock) function Clock.Pause(self: Clock)
if self.Connection then if self.Connection then
self.Connection:Disconnect() self.Connection:disconnect()
end end
end end
function Clock.Resume(self: Clock) function Clock.Resume(self: Clock)
if self.Connection.Connected then if self.Connection.connected then
return return
end end

View File

@ -1,7 +1,7 @@
--!strict --!strict
-- A basic polyfill for the typeof function -- A basic polyfill for the typeof function
return function(value) return function(value: any): string
local basicType = type(value) local basicType = type(value)
if if

1374
defs.d.lua

File diff suppressed because one or more lines are too long

View File

@ -52,7 +52,7 @@ end)
-- end) -- end)
ScriptContext.ScriptsDisabled = true ScriptContext.ScriptsDisabled = true
-- game:SetPlaceID(nil, false) -- game:SetPlaceId(nil, false)
ChangeHistoryService:SetEnabled(false) ChangeHistoryService:SetEnabled(false)
if url ~= nil then if url ~= nil then

View File

@ -11,7 +11,7 @@ local Visit = game:GetService "Visit"
local player, connectionFailed local player, connectionFailed
pcall(function() pcall(function()
game:SetPlaceID(_PLACE_ID, false) game:SetPlaceId(_PLACE_ID, false)
end) end)
-- if we are on a touch device, no blocking http calls allowed! This can cause a crash on iOS -- if we are on a touch device, no blocking http calls allowed! This can cause a crash on iOS
@ -22,9 +22,6 @@ settings()["Game Options"].CollisionSoundEnabled = true
pcall(function() pcall(function()
settings().Rendering.EnableFRM = true settings().Rendering.EnableFRM = true
end) end)
pcall(function()
settings().Physics.Is30FpsThrottleEnabled = false
end)
pcall(function() pcall(function()
settings()["Task Scheduler"].PriorityMethod = settings()["Task Scheduler"].PriorityMethod =
Enum.PriorityMethod.AccumulatedError Enum.PriorityMethod.AccumulatedError

View File

@ -15,7 +15,7 @@ local player
-- Prepended to Edit.lua and Visit.lua and Studio.lua and PlaySolo.lua-- -- Prepended to Edit.lua and Visit.lua and Studio.lua and PlaySolo.lua--
pcall(function() pcall(function()
return game:SetPlaceID(_PLACE_ID) game:SetPlaceId(_PLACE_ID)
end) end)
local message = Instance.new "Message" local message = Instance.new "Message"