User talk:Sduke524/SumoBots/Rings

From Legacy Roblox Wiki
Revision as of 22:28, 18 March 2012 by >NXTBoy (Created page with "==Suggested replacement== {{lua|= function new(obj, f) obj = Instance.new(obj) return f and f(obj) or obj end function range(t) local to, from = t[1] or t[0], t[1] and t[0]...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Suggested replacement

function new(obj, f) obj = Instance.new(obj) return f and f(obj) or obj 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

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

	new("Part", function(center)
		center.Name = "Center"
		center.Anchored = true
		center.BrickColor = BrickColor.new("White")
		center.TopSurface = "Smooth"
		center.BottomSurface = "Smooth"
		center.formFactor = "Custom"
		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)

		new("Part", function(inner)
			inner.Name = "Inner"
			inner.Anchored = true
			inner.BrickColor = BrickColor.new("Really black")
			inner.TopSurface = "Smooth"
			inner.BottomSurface = "Smooth"
			inner.formFactor = "Custom"
			inner.Size = Vector3.new(10.1, 0.3, radius)
			inner.CFrame = cf * CFrame.new(0, 0, radius / 2)
		end).Parent = ring

		new("Part", function(outer)
			outer.Name = "Outer"
			outer.Anchored = true
			outer.BrickColor = BrickColor.new("White")
			outer.TopSurface = "Smooth"
			outer.BottomSurface = "Smooth"
			outer.formFactor = "Custom"
			outer.Size = Vector3.new(11, 0.3, 2)
			outer.CFrame = cf * CFrame.new(0, 0, radius + 1)
		end).Parent = ring
	end
end).Parent = workspace