mirror of
https://github.com/copyrighttxt/watrbx-game-engine.git
synced 2026-09-04 20:57:49 +00:00
111 lines
3.8 KiB
Plaintext
111 lines
3.8 KiB
Plaintext
function start(placeId, port, url)
|
|
------------------- UTILITY FUNCTIONS --------------------------
|
|
|
|
|
|
function waitForChild(parent, childName)
|
|
while true do
|
|
local child = parent:findFirstChild(childName)
|
|
if child then
|
|
return child
|
|
end
|
|
parent.ChildAdded:wait()
|
|
end
|
|
end
|
|
|
|
-----------------------------------END UTILITY FUNCTIONS -------------------------
|
|
|
|
-----------------------------------"CUSTOM" SHARED CODE----------------------------------
|
|
|
|
pcall(function() settings().Network.UseInstancePacketCache = true end)
|
|
pcall(function() settings().Network.UsePhysicsPacketCache = true end)
|
|
--pcall(function() settings()["Task Scheduler"].PriorityMethod = Enum.PriorityMethod.FIFO end)
|
|
pcall(function() settings()["Task Scheduler"].PriorityMethod = Enum.PriorityMethod.AccumulatedError end)
|
|
|
|
--settings().Network.PhysicsSend = 1 -- 1==RoundRobin
|
|
--settings().Network.PhysicsSend = Enum.PhysicsSendMethod.ErrorComputation2
|
|
settings().Network.PhysicsSend = Enum.PhysicsSendMethod.TopNErrors
|
|
settings().Network.ExperimentalPhysicsEnabled = true
|
|
settings().Network.WaitingForCharacterLogRate = 100
|
|
pcall(function() settings().Diagnostics:LegacyScriptMode() end)
|
|
|
|
-----------------------------------START GAME SHARED SCRIPT------------------------------
|
|
|
|
local assetId = placeId -- might be able to remove this now
|
|
|
|
local scriptContext = game:GetService('ScriptContext')
|
|
pcall(function() scriptContext:AddStarterScript(37801172) end)
|
|
scriptContext.ScriptsDisabled = true
|
|
|
|
game:SetPlaceID(assetId, false)
|
|
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
|
|
|
-- establish this peer as the Server
|
|
local ns = game:GetService("NetworkServer")
|
|
|
|
if url~=nil then
|
|
pcall(function() game:GetService("Players"):SetAbuseReportUrl(url .. "/AbuseReport/InGameChatHandler.ashx") end)
|
|
pcall(function() game:GetService("ScriptInformationProvider"):SetAssetUrl(url .. "/Asset/") end)
|
|
pcall(function() game:GetService("ContentProvider"):SetBaseUrl(url .. "/") end)
|
|
pcall(function() game:GetService("Players"):SetChatFilterUrl(url .. "/Game/ChatFilter.ashx") end)
|
|
|
|
game:GetService("BadgeService"):SetPlaceId(placeId)
|
|
|
|
game:GetService("BadgeService"):SetIsBadgeLegalUrl("")
|
|
game:GetService("InsertService"):SetBaseSetsUrl(url .. "/Game/Tools/InsertAsset.ashx?nsets=10&type=base")
|
|
game:GetService("InsertService"):SetUserSetsUrl(url .. "/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d")
|
|
game:GetService("InsertService"):SetCollectionUrl(url .. "/Game/Tools/InsertAsset.ashx?sid=%d")
|
|
game:GetService("InsertService"):SetAssetUrl(url .. "/Asset/?id=%d")
|
|
game:GetService("InsertService"):SetAssetVersionUrl(url .. "/Asset/?assetversionid=%d")
|
|
|
|
pcall(function() loadfile(url .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end)
|
|
|
|
-- pcall(function()
|
|
-- if access then
|
|
-- loadfile(url .. "/Game/PlaceSpecificScript.ashx?PlaceId=" .. placeId .. "&" .. access)()
|
|
-- end
|
|
-- end)
|
|
end
|
|
|
|
--pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end)
|
|
settings().Diagnostics.LuaRamLimit = 0
|
|
--settings().Network:SetThroughputSensitivity(0.08, 0.01)
|
|
--settings().Network.SendRate = 35
|
|
--settings().Network.PhysicsSend = 0 -- 1==RoundRobin
|
|
|
|
|
|
game:GetService("Players").PlayerAdded:connect(function(player)
|
|
print("Player " .. player.userId .. " added")
|
|
end)
|
|
|
|
game:GetService("Players").PlayerRemoving:connect(function(player)
|
|
print("Player " .. player.userId .. " leaving")
|
|
end)
|
|
|
|
if placeId~=nil and url~=nil then
|
|
-- yield so that file load happens in the heartbeat thread
|
|
wait()
|
|
|
|
-- load the game
|
|
game:Load(url .. "/asset/?id=" .. placeId)
|
|
end
|
|
|
|
-- Now start the connection
|
|
ns:Start(port)
|
|
|
|
|
|
scriptContext:SetTimeout(10)
|
|
scriptContext.ScriptsDisabled = false
|
|
|
|
print("ratted")
|
|
|
|
------------------------------END START GAME SHARED SCRIPT--------------------------
|
|
|
|
|
|
|
|
-- StartGame --
|
|
game:GetService("RunService"):Run()
|
|
|
|
|
|
end
|
|
|