null
nil
-
[RBX1]
0
0
0
0
1
0
0
0
1
0
0
0
1
Workspace
[null]
-
[null]
0
64.6447144
30.3143482
0.148706198
-9.34668424e-006
-0.16160965
0.986854732
-0
0.986854732
0.16160965
-1
1.51051438e-006
-9.22381878e-006
70
44.9076195
27.0821552
0.148890674
1
0
0
0
1
0
0
0
1
Camera
-
true
true
-0.5
0.5
0
0
-0.5
0.5
4
0
194
-2
126
-2
1
0
0
0
1
0
0
0
1
true
0.5
0.300000012
-0.5
0.5
0
0
-0.5
0.5
0
0
true
256
Terrain
0
-0.5
0.5
0
0
0
0
0
-0.5
0.5
3
0
0
0
0
0
2044
252
2044
-
true
ClockMaker
-- goal is to create (recursively) a planet-system..
local numRings = 6
local numPartsPerRing = 5
local ClockModel = Instance.new("Model", game.Workspace)
ClockModel.Name = "ClockModel"
local rotationBases = {CFrame.new(), CFrame.Angles(0, math.pi/2, 0), CFrame.Angles(0, 0, -math.pi/2), CFrame.Angles(math.pi/2, 0, 0)}
local keyPart = Instance.new("Part")
keyPart.formFactor = "Custom"
keyPart.Size = Vector3.new(numRings + 2, numRings + 2, numRings + 2)
keyPart.Anchored = false
--keyPart.Anchored = true
keyPart.CanCollide = false
keyPart.CFrame = CFrame.new(Vector3.new(0, 300, 0))
--keyPart.Parent = game.Workspace
keyPart.Name = "Torso"
--local newBP = Instance.new("BodyPosition")
--newBP.P = 900000
--newBP.maxForce = Vector3.new(newBP.P, newBP.P, newBP.P)
--newBP.position = keyPart.CFrame.p
--newBP.Parent = keyPart
-- figure out total mass of contraption here
-- mass is (numRings+2)^3 + numPartsPerRing*(numRings)^3 + numPartsPerRing^2(numRings-1)^3 + numPartsPerRing^3(numRings-2)^3 + ...
local totalMass = (numRings+2)*(numRings+2)*(numRings+2)
local multiplier = numPartsPerRing
for i = numRings, 1, -1 do
totalMass = totalMass + multiplier*i*i*i
multiplier = multiplier * numPartsPerRing
end
local newBF = Instance.new("BodyForce")
newBF.force = Vector3.new(0, totalMass*196.2, 0)
newBF.Parent = keyPart
keyPart.Parent = ClockModel
--Instance.new("Humanoid", ClockModel)
local colorTable = {BrickColor.new("Really red"), BrickColor.new("Really blue"), BrickColor.new("Camo"), BrickColor.new("Lime green"), BrickColor.new("Black"), BrickColor.new("New Yeller"), BrickColor.random(), BrickColor.random(), BrickColor.random()}
function createSystem(mainPart, numLevels, numPartsPerLevel)
if numLevels <= 0 then return end
for i = 1, numPartsPerLevel do
-- figure out where to put slave part
local alpha = math.pi*2*i/numPartsPerLevel
--local slaveRadius = math.pow(4, numLevels)
local slaveRadius = math.pow(2.2, numLevels) -- was 2.5
local slavePartLocation = mainPart.CFrame.p + slaveRadius * Vector3.new(math.cos(alpha), 0, math.sin(alpha))
-- create the slave part
local slavePart = mainPart:Clone()
--local slaveBP = slavePart:FindFirstChild("BodyPosition")
--if slaveBP then slaveBP:Remove() end
local slaveBF = slavePart:FindFirstChild("BodyForce")
if slaveBF then slaveBF:Remove() end
slavePart.Name = "ClockPart"
slavePart.Size = Vector3.new(numLevels, numLevels, numLevels)
slavePart.Anchored = false
--local slaveBF = slavePart:FindFirstChild("BodyForce")
--if slaveBF then slaveBF.force = Vector3.new(0, slavePart:GetMass()*196.1, 0) end
--slavePart.Anchored = true
slavePart.CFrame = CFrame.new(slavePartLocation)
slavePart.BrickColor = colorTable[numLevels]
-- create a motor so main part swings around slave part
local newMotor = Instance.new("Motor6D")
newMotor.Part0 = mainPart
newMotor.Part1 = slavePart
--newMotor.C0 = CFrame.new()
newMotor.C0 = rotationBases[numLevels % (#rotationBases) + 1]
newMotor.C1 = slavePart.CFrame:inverse()*mainPart.CFrame
newMotor.MaxVelocity = .02 * (numRings + 1 - numLevels)
newMotor.DesiredAngle = 2*math.pi*( numRings + 1 - numLevels)
--newMotor.Parent = slavePart
newMotor.Parent = keyPart
--slavePart.Parent = game.Workspace
--local newHumanoid = Instance.new("Humanoid", slavePart)
slavePart.Parent = ClockModel
-- keep going!
createSystem(slavePart, numLevels - 1, numPartsPerLevel)
end
end
createSystem(keyPart, numRings, numPartsPerRing)
-
StarterPack
-
StarterGui
true
-
0
10
1
Soundscape
1
-
CollectionService
-
PhysicsService
-
BadgeService
-
Geometry
-
RenderHooksService
-
SocialService
-
1000
Debris
-
Instance
-
Instance
-
CookiesService
-
Teleport Service
-
true
Players
-
Selection
-
4286611584
1
4278190080
4278190080
4290822336
100000
0
41.7332993
Lighting
4289967032
14:00:00
-
ChangeHistoryService
-
true
false
false
false
TestService
600
-
false
TestScript
local numSecondsToRunFor = 11 -- number of physics seconds to run for (for stress tests, could take much longer in realtime)
game.Workspace.ClockMaker.Disabled = false
r = game:GetService("RunService")
r:Pause()
local clockModel = game.Workspace:FindFirstChild("ClockModel")
while not clockModel do game.Workspace.ChildAdded:wait() clockModel = game.Workspace:FindFirstChild("ClockModel") end
local numRings = 6
local numPartsPerRing = 5
-- because 1 + x + x^2 + x^3 + ... + x^k = [x^(k+1) - 1]/(x - 1)
local numClockParts = (math.pow(numPartsPerRing, numRings+1) - 1) / (numPartsPerRing - 1)
--[[local multiplier = numPartsPerRing
local numClockParts = 1
for i = numRings, 1, -1 do
numClockParts = numClockParts + multiplier
multiplier = multiplier * numPartsPerRing
end]]
local numClockChildren = #(clockModel:GetChildren())
while numClockChildren < numClockParts do wait() numClockChildren = #(clockModel:GetChildren()) end
local cframeCheckTable = {}
local clockParts = clockModel:GetChildren()
for i = 1, #clockParts do
table.insert(cframeCheckTable, clockParts[i].CFrame)
end
r:Run()
start = tick()
--r = game:service("RunService")
t = r.Stepped:wait()
local startT = t
while (t - startT) < numSecondsToRunFor do
t = r.Stepped:wait()
end
stop = tick() - start
-- just making it here without getting timed out is the win
print(script.Parent.Name .. " passed in " .. stop .. " seconds.")
script.Parent:Check(true, "passed in " .. stop .. " seconds.")
local errorSq = 0
for i = 1, #clockParts do
local miniError = (cframeCheckTable[i].p - clockParts[i].CFrame.p)
errorSq = errorSq + miniError:Dot(miniError)
end
print("Accuracy check (MSE): ", errorSq)
script.Parent:Check(errorSq < .001, "passed accuracy test.")