User talk:Sduke524/SumoBots/Rings

From Legacy Roblox Wiki
Jump to navigationJump to search

Suggested replacement

function with(obj, f) return f and f(obj) or obj end
function new(obj, f) return with(Instance.new(obj), f) end

function range(t)
	local to, from = t[1] or t[0],  t[1] and t[0] or 0
	local span, i = to - from, 0
	local steps = t.steps or span / t.step
	return function()
		if i < steps then
			local n = from + span * i/steps
			i = i + 1
			return n
		end
	end
end

local itr = 25
local position = CFrame.new(0, 0.2, 0)
local radius = 40

local cleanPart = new("Part", function(p)
	p.Anchored      = true
	p.TopSurface    = "Smooth"
	p.BottomSurface = "Smooth"
	p.formFactor    = "Custom"
	p.BrickColor    = BrickColor.new("White")
end)

new("Model", function(ring)
	ring.Name = "Ring"

	with(cleanPart:clone(), function(center)
		center.Name   = "Center"
		center.Size   = Vector3.new(20, 0.31, 20)
		center.CFrame = position
		new("CylinderMesh").Parent = center
	end).Parent = ring

	for angle in range{2*math.pi, steps = itr} do
		local cf = position * CFrame.Angles(0, angle, 0)

		with(cleanPart:clone(), function(inner)
			inner.Name       = "Inner"
			inner.BrickColor = BrickColor.new("Really black")
			inner.Size       = Vector3.new(10.1, 0.3, radius)
			inner.CFrame     = cf * CFrame.new(0, 0, radius / 2)
		end).Parent = ring

		with(cleanPart:clone(), function(outer)
			outer.Name   = "Outer"
			outer.Size   = Vector3.new(11, 0.3, 2)
			outer.CFrame = cf * CFrame.new(0, 0, radius + 1)
		end).Parent = ring
	end
end).Parent = workspace
22:37, 18 March 2012 (UTC)